ghostfolio/apps/api/src/app/app.module.ts

93 lines
3.5 KiB
TypeScript
Raw Normal View History

2021-04-13 21:53:58 +02:00
import { join } from 'path';
import { AuthDeviceModule } from '@ghostfolio/api/app/auth-device/auth-device.module';
import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module';
import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module';
import { CronService } from '@ghostfolio/api/services/cron.service';
import { DataGatheringModule } from '@ghostfolio/api/services/data-gathering.module';
import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module';
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
import { TwitterBotModule } from '@ghostfolio/api/services/twitter-bot/twitter-bot.module';
import { BullModule } from '@nestjs/bull';
2022-08-15 18:17:57 +02:00
import { MiddlewareConsumer, Module, RequestMethod } from '@nestjs/common';
2021-04-13 21:53:58 +02:00
import { ConfigModule } from '@nestjs/config';
import { ScheduleModule } from '@nestjs/schedule';
import { ServeStaticModule } from '@nestjs/serve-static';
import { AccessModule } from './access/access.module';
import { AccountModule } from './account/account.module';
2021-04-13 21:53:58 +02:00
import { AdminModule } from './admin/admin.module';
import { AppController } from './app.controller';
import { AuthModule } from './auth/auth.module';
import { BenchmarkModule } from './benchmark/benchmark.module';
2021-04-13 21:53:58 +02:00
import { CacheModule } from './cache/cache.module';
import { ExportModule } from './export/export.module';
2022-08-15 18:17:57 +02:00
import { FrontendMiddleware } from './frontend.middleware';
import { ImportModule } from './import/import.module';
2021-04-13 21:53:58 +02:00
import { InfoModule } from './info/info.module';
import { OrderModule } from './order/order.module';
import { PortfolioModule } from './portfolio/portfolio.module';
import { SubscriptionModule } from './subscription/subscription.module';
2021-04-13 21:53:58 +02:00
import { SymbolModule } from './symbol/symbol.module';
import { UserModule } from './user/user.module';
@Module({
imports: [
AdminModule,
AccessModule,
AccountModule,
AuthDeviceModule,
2021-04-13 21:53:58 +02:00
AuthModule,
BenchmarkModule,
BullModule.forRoot({
redis: {
host: process.env.REDIS_HOST,
port: parseInt(process.env.REDIS_PORT, 10),
password: process.env.REDIS_PASSWORD
}
}),
2021-04-13 21:53:58 +02:00
CacheModule,
ConfigModule.forRoot(),
ConfigurationModule,
DataGatheringModule,
DataProviderModule,
ExchangeRateDataModule,
ExportModule,
ImportModule,
2021-04-13 21:53:58 +02:00
InfoModule,
OrderModule,
PortfolioModule,
PrismaModule,
2021-04-13 21:53:58 +02:00
RedisCacheModule,
ScheduleModule.forRoot(),
ServeStaticModule.forRoot({
serveStaticOptions: {
/*etag: false // Disable etag header to fix PWA
setHeaders: (res, path) => {
if (path.includes('ngsw.json')) {
// Disable cache (https://stackoverflow.com/questions/22632593/how-to-disable-webpage-caching-in-expressjs-nodejs/39775595)
// https://gertjans.home.xs4all.nl/javascript/cache-control.html#no-cache
res.set('Cache-Control', 'no-cache, no-store, must-revalidate');
}
}*/
},
rootPath: join(__dirname, '..', 'client'),
exclude: ['/api*']
}),
SubscriptionModule,
2021-04-13 21:53:58 +02:00
SymbolModule,
TwitterBotModule,
2021-04-13 21:53:58 +02:00
UserModule
],
controllers: [AppController],
providers: [CronService]
2021-04-13 21:53:58 +02:00
})
2022-08-15 18:17:57 +02:00
export class AppModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(FrontendMiddleware)
.forRoutes({ path: '*', method: RequestMethod.ALL });
}
}