fix: bug in the content type parser of fastify

This commit is contained in:
mahyargdz
2025-04-22 15:41:56 +03:30
parent 5883890e7f
commit 8598ffe67b
4 changed files with 22 additions and 4 deletions
+9 -1
View File
@@ -50,7 +50,15 @@ import { WalletsModule } from "./modules/wallets/wallets.module";
CacheModule.registerAsync(cacheConfig()),
TypeOrmModule.forRootAsync(databaseConfigs()),
HttpModule.register({ global: true, timeout: 10000, headers: { "Content-Type": "application/json" } }),
FastifyMulterModule,
FastifyMulterModule.register({
limits: {
fileSize: 10 * 1024 * 1024,
fieldNameSize: 200,
fieldSize: 10 * 1024 * 1024,
fields: 10,
parts: 10,
},
}),
AuthModule,
UsersModule,
TicketsModule,
+11 -1
View File
@@ -10,7 +10,17 @@ import { PaginationInterceptor } from "./core/interceptors/pagination.intercepto
import { ResponseInterceptor } from "./core/interceptors/response.interceptor";
async function bootstrap() {
const logger = new Logger("APP");
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
const fastifyAdapter = new FastifyAdapter({
bodyLimit: 10 * 1024 * 1024,
});
// Add multipart content type parser
fastifyAdapter.getInstance().addContentTypeParser("multipart/form-data", (_request, _payload, done) => {
done(null);
});
const app = await NestFactory.create<NestFastifyApplication>(AppModule, fastifyAdapter);
app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true }));
app.useGlobalInterceptors(new ResponseInterceptor(), new PaginationInterceptor(), new ClassSerializerInterceptor(app.get(Reflector)));
@@ -384,7 +384,7 @@ export class DiscountsService {
});
for (const plan of subscriptionPlans) {
plan.directDiscount = null!;
plan.directDiscount = null;
plan.price = new Decimal(plan.originalPrice);
await queryRunner.manager.save(SubscriptionPlan, plan);
}
@@ -32,7 +32,7 @@ export class SubscriptionPlan extends BaseEntity {
userSubscriptions: UserSubscription[];
@ManyToOne(() => Discount, (discount) => discount.subscriptionPlans, { nullable: true, onUpdate: "CASCADE" })
directDiscount?: Discount;
directDiscount: Discount | null;
@DeleteDateColumn({ nullable: true })
deletedAt?: Date;