2022-12-01 23:07:49 +01:00
|
|
|
import { HttpException, HttpStatus, Module } from "@nestjs/common";
|
2022-11-28 15:04:32 +01:00
|
|
|
|
2022-10-09 22:30:32 +02:00
|
|
|
import { ScheduleModule } from "@nestjs/schedule";
|
|
|
|
import { AuthModule } from "./auth/auth.module";
|
|
|
|
|
2022-12-01 23:07:49 +01:00
|
|
|
import { MulterModule } from "@nestjs/platform-express";
|
2022-12-02 20:17:28 +01:00
|
|
|
import { ThrottlerModule } from "@nestjs/throttler";
|
2022-12-01 23:07:49 +01:00
|
|
|
import { Request } from "express";
|
2022-11-28 15:04:32 +01:00
|
|
|
import { ConfigModule } from "./config/config.module";
|
|
|
|
import { ConfigService } from "./config/config.service";
|
|
|
|
import { EmailModule } from "./email/email.module";
|
2022-10-09 22:30:32 +02:00
|
|
|
import { FileModule } from "./file/file.module";
|
|
|
|
import { PrismaModule } from "./prisma/prisma.module";
|
|
|
|
import { ShareModule } from "./share/share.module";
|
2022-12-02 23:00:24 +01:00
|
|
|
import { UserModule } from "./user/user.module";
|
2022-12-10 17:16:49 +01:00
|
|
|
import { JobsModule } from "./jobs/jobs.module";
|
2022-10-09 22:30:32 +02:00
|
|
|
|
|
|
|
@Module({
|
|
|
|
imports: [
|
|
|
|
AuthModule,
|
|
|
|
ShareModule,
|
|
|
|
FileModule,
|
2022-11-11 15:12:16 +01:00
|
|
|
EmailModule,
|
2022-10-09 22:30:32 +02:00
|
|
|
PrismaModule,
|
2022-11-28 15:04:32 +01:00
|
|
|
ConfigModule,
|
2022-12-10 17:16:49 +01:00
|
|
|
JobsModule,
|
2022-12-02 23:00:24 +01:00
|
|
|
UserModule,
|
2022-12-01 23:07:49 +01:00
|
|
|
MulterModule.registerAsync({
|
|
|
|
useFactory: (config: ConfigService) => ({
|
|
|
|
fileFilter: (req: Request, file, cb) => {
|
2022-12-05 16:53:52 +01:00
|
|
|
const MAX_FILE_SIZE = config.get("MAX_FILE_SIZE");
|
2022-12-01 23:07:49 +01:00
|
|
|
const requestFileSize = parseInt(req.headers["content-length"]);
|
2022-12-05 16:53:52 +01:00
|
|
|
const isValidFileSize = requestFileSize <= MAX_FILE_SIZE;
|
2022-12-01 23:07:49 +01:00
|
|
|
cb(
|
|
|
|
!isValidFileSize &&
|
|
|
|
new HttpException(
|
2022-12-05 16:53:52 +01:00
|
|
|
`File must be smaller than ${MAX_FILE_SIZE} bytes`,
|
2022-12-01 23:07:49 +01:00
|
|
|
HttpStatus.PAYLOAD_TOO_LARGE
|
|
|
|
),
|
|
|
|
isValidFileSize
|
|
|
|
);
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
inject: [ConfigService],
|
|
|
|
}),
|
2022-10-24 12:11:10 +02:00
|
|
|
ThrottlerModule.forRoot({
|
|
|
|
ttl: 60,
|
|
|
|
limit: 100,
|
|
|
|
}),
|
2022-10-09 22:30:32 +02:00
|
|
|
ScheduleModule.forRoot(),
|
|
|
|
],
|
|
|
|
})
|
|
|
|
export class AppModule {}
|