feat: update validation and exception handling, refactor controller routes, and enhance sales invoice item DTO
- Removed global validation pipe and added a new ValidationExceptionFilter for better error handling. - Refactored controller routes to use underscores instead of hyphens for consistency. - Updated CreateSalesInvoiceItemDto to include new fields: quantity, unit_type, and payload. - Modified CreateSalesInvoiceDto to enforce items as an array with a minimum size. - Added Enums module to provide gold karat values through a dedicated endpoint. - Introduced new columns in the database schema for sales invoice items and goods.
This commit is contained in:
+5
-4
@@ -1,9 +1,10 @@
|
||||
import { ValidationPipe, VersioningType } from '@nestjs/common'
|
||||
import { VersioningType } from '@nestjs/common'
|
||||
import { NestFactory, Reflector } from '@nestjs/core'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
|
||||
import { AppModule } from './app.module'
|
||||
import { PrismaExceptionFilter } from './common/filters/prisma-exception.filter'
|
||||
import { ValidationExceptionFilter } from './common/filters/validation-exception.filter'
|
||||
import { LoggingInterceptor } from './common/interceptors/logging.interceptor'
|
||||
import { ResponseMappingInterceptor } from './common/interceptors/response-mapping.interceptor'
|
||||
import { JwtAuthGuard } from './modules/auth/jwt-auth.guard'
|
||||
@@ -58,10 +59,10 @@ async function bootstrap() {
|
||||
app.useGlobalInterceptors(new LoggingInterceptor(), new ResponseMappingInterceptor())
|
||||
|
||||
// Enable request validation and transformation globally
|
||||
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }))
|
||||
// app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }))
|
||||
|
||||
// Register global exception filter to map Prisma and validation errors to proper HTTP codes
|
||||
app.useGlobalFilters(new PrismaExceptionFilter())
|
||||
// Register global exception filters: validation errors and Prisma errors
|
||||
app.useGlobalFilters(new ValidationExceptionFilter(), new PrismaExceptionFilter())
|
||||
|
||||
app.useGlobalGuards(new JwtAuthGuard(app.get(JwtService), app.get(Reflector)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user