-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.module.ts
30 lines (29 loc) · 897 Bytes
/
app.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {
MiddlewareConsumer,
Module,
NestModule,
RequestMethod,
} from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UsersModule } from './users/users.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { TokenBlacklistModule } from './token-blacklist/token-blacklist.module';
import { dataSourceOptions } from 'db/data-source';
import { CurrentUserMiddleware } from './utility/middleware/current-user.middleware';
@Module({
imports: [
TypeOrmModule.forRoot(dataSourceOptions),
UsersModule,
TokenBlacklistModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(CurrentUserMiddleware)
.forRoutes({ path: '*', method: RequestMethod.ALL });
}
}