57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
import { BadRequestException, Module, ValidationPipe } from '@nestjs/common';
|
|
import { AppController } from './app.controller';
|
|
import { AppService } from './app.service';
|
|
import { PrismaPostgresModule } from '../prisma/postgres/prisma-postgres.module';
|
|
import { ScheduleModule } from '@nestjs/schedule';
|
|
import { ConfigModule } from '@nestjs/config';
|
|
import { APP_FILTER, APP_PIPE } from '@nestjs/core';
|
|
import { HttpExceptionFilter } from './common/filters/http-exception.filter';
|
|
import { ValidationError } from 'class-validator';
|
|
import { TimeAndAttendanceModule } from 'src/time-and-attendance/time-and-attendance.module';
|
|
import { AuthenticationModule } from 'src/identity-and-account/authentication/auth.module';
|
|
import { IdentityAndAccountModule } from 'src/identity-and-account/identity-and-account.module';
|
|
import { ChatbotModule } from 'src/chatbot/chatbot.module';
|
|
import { PrismaMariadbModule } from 'prisma/mariadb/prisma-mariadb.module';
|
|
import { PrismaLegacyModule } from 'prisma/prisma-legacy/prisma-legacy.module';
|
|
import { CustomerSupportModule } from 'src/customer-support/customer-support.module';
|
|
|
|
@Module({
|
|
imports: [
|
|
AuthenticationModule,
|
|
ConfigModule.forRoot({ isGlobal: true }),
|
|
ScheduleModule.forRoot(), //cronjobs
|
|
PrismaPostgresModule,
|
|
PrismaMariadbModule,
|
|
PrismaLegacyModule,
|
|
TimeAndAttendanceModule,
|
|
IdentityAndAccountModule,
|
|
ChatbotModule,
|
|
CustomerSupportModule,
|
|
],
|
|
controllers: [AppController],
|
|
providers: [
|
|
AppService,
|
|
{
|
|
provide: APP_FILTER,
|
|
useClass: HttpExceptionFilter
|
|
},
|
|
{
|
|
provide: APP_PIPE,
|
|
useValue: new ValidationPipe({
|
|
whitelist: true,
|
|
forbidNonWhitelisted: true,
|
|
transform: true,
|
|
exceptionFactory: (errors: ValidationError[] = []) => {
|
|
const messages = errors.flatMap((e) => Object.values(e.constraints ?? {}));
|
|
return new BadRequestException({
|
|
statusCode: 400,
|
|
error: 'Bad Request',
|
|
message: messages.length ? messages : errors,
|
|
});
|
|
},
|
|
}),
|
|
},
|
|
],
|
|
})
|
|
export class AppModule { }
|