|
@@ -3,6 +3,8 @@ import { AppModule } from './app.module';
|
|
|
import { SnowflakeUtil } from './core/util/snowflake.util';
|
|
import { SnowflakeUtil } from './core/util/snowflake.util';
|
|
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
|
import { ValidationPipe } from '@nestjs/common';
|
|
import { ValidationPipe } from '@nestjs/common';
|
|
|
|
|
+import { GlobalExceptionFilter } from './core/exceptions/global-exception.filter';
|
|
|
|
|
+import { GlobalValidationPipe } from './core/pipe/global-validation.pipe';
|
|
|
|
|
|
|
|
async function bootstrap() {
|
|
async function bootstrap() {
|
|
|
SnowflakeUtil.initialize(
|
|
SnowflakeUtil.initialize(
|
|
@@ -15,16 +17,17 @@ async function bootstrap() {
|
|
|
.setTitle(process.env.APP_TITLE)
|
|
.setTitle(process.env.APP_TITLE)
|
|
|
.setDescription('The api description')
|
|
.setDescription('The api description')
|
|
|
.setVersion('1.0')
|
|
.setVersion('1.0')
|
|
|
|
|
+
|
|
|
.build();
|
|
.build();
|
|
|
const document = SwaggerModule.createDocument(app, config);
|
|
const document = SwaggerModule.createDocument(app, config);
|
|
|
- SwaggerModule.setup('docs', app, document);
|
|
|
|
|
|
|
+ SwaggerModule.setup('docs', app, document, {
|
|
|
|
|
+ jsonDocumentUrl: 'docs/json',
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- app.useGlobalPipes(
|
|
|
|
|
- new ValidationPipe({
|
|
|
|
|
- transform: true,
|
|
|
|
|
- }),
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ app.useGlobalPipes(new GlobalValidationPipe());
|
|
|
|
|
+ app.useGlobalFilters(new GlobalExceptionFilter());
|
|
|
|
|
+
|
|
|
await app.listen(3000);
|
|
await app.listen(3000);
|
|
|
}
|
|
}
|
|
|
bootstrap();
|
|
bootstrap();
|