@lenne.tech/nest-server 11.42.6 → 11.42.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/main.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { NestFactory } from '@nestjs/core';
2
2
  import { NestExpressApplication } from '@nestjs/platform-express';
3
- import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
4
3
  import { exec } from 'child_process';
5
4
  import compression = require('compression');
6
5
  import cookieParser = require('cookie-parser');
@@ -11,6 +10,7 @@ import { buildCorsConfig, isCookiesEnabled, isCorsDisabled } from './core/common
11
10
  import { HttpExceptionLogFilter } from './core/common/filters/http-exception-log.filter';
12
11
  import { installGracefulShutdown } from './core/common/helpers/graceful-shutdown.helper';
13
12
  import { handleFatalBootstrapError, installProcessDiagnostics } from './core/common/helpers/process-diagnostics.helper';
13
+ import { setupSwagger } from './core/common/helpers/swagger.helper';
14
14
  import { CorePersistenceModel } from './core/common/models/core-persistence.model';
15
15
  import { CoreAuthModel } from './core/modules/auth/core-auth.model';
16
16
  import { CoreUserModel } from './core/modules/user/core-user.model';
@@ -96,21 +96,15 @@ async function bootstrap() {
96
96
  // to avoid open CORS with credentials). Callers should configure appUrl/baseUrl/allowedOrigins.
97
97
  }
98
98
 
99
- // Swagger documentation
100
- const config = new DocumentBuilder()
101
- .setTitle('Nest Server API')
102
- .setDescription('API lenne.Tech Nest Server')
103
- .setVersion('1.0.0')
104
- .addBearerAuth()
105
- .build();
106
- const documentFactory = () =>
107
- SwaggerModule.createDocument(server, config, {
108
- autoTagControllers: true,
109
- deepScanRoutes: true,
99
+ // Swagger documentation: security, API-token scopes and the tenant header are read from the same
100
+ // decorators the guards read (see setupSwagger), so "Authorize" applies to every route.
101
+ setupSwagger(server, {
102
+ description: 'API lenne.Tech Nest Server',
103
+ documentOptions: {
110
104
  extraModels: [CoreUserModel, CoreAuthModel, Auth, User, PersistenceModel, CorePersistenceModel, FilterArgs],
111
- });
112
- SwaggerModule.setup('swagger', server, documentFactory, {
113
- jsonDocumentUrl: '/api-docs-json',
105
+ },
106
+ title: 'Nest Server API',
107
+ version: '1.0.0',
114
108
  });
115
109
 
116
110
  // Drain the event loop on SIGTERM/SIGINT so the process actually exits.