samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.81k stars 94 forks source link

"exclude" option not considered while using app.setGlobalPrefix(..) in nestia.config.ts #746

Open sourav-bhar opened 8 months ago

sourav-bhar commented 8 months ago

Summary

When calling the app.setGlobalPrefix(...) function in nestia.config.ts, it appears that the paths mentioned in the "exclude" option are also getting the global prefix (see example below). The correct behavior is that such paths should be excluded from the global prefix. When the SDK generates the fetch function for such routes, it should not apply the global prefix to their paths.

Code where the bug is occuring:

import { INestiaConfig } from '@nestia/sdk';
import { VERSION_NEUTRAL, VersioningType } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { initializeApp } from 'firebase-admin/app';
import { AppModule } from './src/app/app.module';

const NESTIA_CONFIG: INestiaConfig = {
  input: async () => {
    initializeApp();

    const app = await NestFactory.create(AppModule, {
      bodyParser: false,
    });

    app.setGlobalPrefix('api', { exclude: ['/_ah/warmup'] });  // 👈 here 

    app.enableVersioning({
      type: VersioningType.URI,
      prefix: 'v',
      defaultVersion: VERSION_NEUTRAL,
    });

    return app;
  },
  output: 'libs/shared/client/api/src',
  clone: true,
  primitive: true,
};
export default NESTIA_CONFIG;
samchon commented 8 months ago

Can you provide a reproducible repo?

sourav-bhar commented 8 months ago

OK, I will provide one tomorrow.