-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.module.ts
50 lines (45 loc) · 1.37 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Module, HttpModule, NestModule, MiddlewareConsumer, OnModuleInit } from '@nestjs/common';
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
import * as fs from 'fs';
import { AuthenticationController } from './controllers/authentication.controller';
//// .....
import { RemoteDbService } from './services/remoteDb.service';
@Module({
imports: [CoreModule],
providers: [JobsService],
exports: [JobsService]
})
export class JobsModule {}
@Module({
imports: [CoreModule, ServiceModule, HttpModule, EventsModule],
controllers: [
AuthenticationController,
//.....
],
providers: [
{
provide: APP_GUARD,
useClass: AuthGuard
},
{
provide: APP_INTERCEPTOR,
useClass: EnvelopeInterceptor
},
]
})
export class ApplicationModule implements NestModule, OnModuleInit {
constructor(private config: Config, private remoteDataBaseService: RemoteDbService) {
}
configure(consumer: MiddlewareConsumer) {
consumer.apply(LoggerMiddleware).forRoutes('*');
}
async onModuleInit() {
this.createVideoTempFolder();
// check if remote databases avaliable
const remoteAvailable = await this.remoteDataBaseService.checkIsRemoteAvailable();
// remove old and create union temp tables from remote databases at each start
if (remoteAvailable) {
await this.remoteDataBaseService.createUnionTables();
}
}
}