Files
dmenu-api/src/app.module.ts
T
2025-11-10 23:23:44 +03:30

52 lines
1.8 KiB
TypeScript

import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import dataBaseConfig from './config/mikro-orm.config';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { UserModule } from './modules/users/user.module';
// import { CacheModule } from '@nestjs/cache-manager';
// import { cacheConfig } from './config/cache.config';
import { UtilsModule } from './modules/utils/utils.module';
// import { HttpModule } from '@nestjs/axios';
// import { httpConfig } from './config/http.config';
import { AuthModule } from './modules/auth/auth.module';
import { JwtModule } from '@nestjs/jwt';
import { UploaderModule } from './modules/uploader/uploader.module';
import { AdminModule } from './modules/admin/admin.module';
// import { CacheService } from './modules/utils/cache.service';
import { ThrottlerModule } from '@nestjs/throttler';
import { RestaurantsModule } from './modules/restaurants/restaurants.module';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true, cache: true }),
MikroOrmModule.forRootAsync(dataBaseConfig),
// CacheModule.registerAsync(cacheConfig()),
JwtModule.registerAsync({
useFactory: (configService: ConfigService) => ({
global: true,
secret: configService.getOrThrow<string>('JWT_SECRET'),
signOptions: {
expiresIn: configService.getOrThrow<number>('JWT_EXPIRATION_TIME'),
},
}),
inject: [ConfigService],
}),
UserModule,
UtilsModule,
AuthModule,
UploaderModule,
AdminModule,
ThrottlerModule.forRoot([
{
ttl: 60, // time window in seconds
limit: 5, // max requests per window
},
]),
RestaurantsModule,
],
controllers: [],
// providers: [CacheService],
// exports: [CacheService],
})
export class AppModule {}