add decks crud

This commit is contained in:
2023-06-17 23:27:23 +02:00
parent 9cd6595ae2
commit 36e54cf56f
23 changed files with 405 additions and 35 deletions

View File

@@ -1,9 +1,10 @@
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { BadRequestException, Logger, ValidationPipe } from '@nestjs/common'
import { Logger } from '@nestjs/common'
import { HttpExceptionFilter } from './exception.filter'
import * as cookieParser from 'cookie-parser'
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import { pipesSetup } from './settings/pipes-setup'
async function bootstrap() {
const app = await NestFactory.create(AppModule)
@@ -15,18 +16,7 @@ async function bootstrap() {
.build()
const document = SwaggerModule.createDocument(app, config)
SwaggerModule.setup('docs', app, document)
app.useGlobalPipes(
new ValidationPipe({
stopAtFirstError: false,
exceptionFactory: errors => {
const customErrors = errors.map(e => {
const firstError = JSON.stringify(e.constraints)
return { field: e.property, message: firstError }
})
throw new BadRequestException(customErrors)
},
})
)
pipesSetup(app)
app.useGlobalFilters(new HttpExceptionFilter())
app.use(cookieParser())
await app.listen(process.env.PORT || 3000)