From 2523df21f28ba125925c1d1156b9e7bbe455d023 Mon Sep 17 00:00:00 2001 From: KenTandrian Date: Tue, 10 Jun 2025 22:04:47 +0700 Subject: [PATCH] feat(api): move HtmlTemplateMiddleware usage to AppModule --- apps/api/src/app/app.module.ts | 13 ++++++++++--- apps/api/src/main.ts | 3 --- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts index 6f512e89b..8bc9c21fd 100644 --- a/apps/api/src/app/app.module.ts +++ b/apps/api/src/app/app.module.ts @@ -1,8 +1,10 @@ import { EventsModule } from '@ghostfolio/api/events/events.module'; +import { HtmlTemplateMiddleware } from '@ghostfolio/api/middlewares/html-template.middleware'; import { ConfigurationModule } from '@ghostfolio/api/services/configuration/configuration.module'; import { CronModule } from '@ghostfolio/api/services/cron/cron.module'; import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module'; import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.module'; +import { I18nService } from '@ghostfolio/api/services/i18n/i18n.service'; import { PrismaModule } from '@ghostfolio/api/services/prisma/prisma.module'; import { PropertyModule } from '@ghostfolio/api/services/property/property.module'; import { DataGatheringModule } from '@ghostfolio/api/services/queues/data-gathering/data-gathering.module'; @@ -13,7 +15,7 @@ import { } from '@ghostfolio/common/config'; import { BullModule } from '@nestjs/bull'; -import { Module } from '@nestjs/common'; +import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { EventEmitterModule } from '@nestjs/event-emitter'; import { ScheduleModule } from '@nestjs/schedule'; @@ -130,6 +132,11 @@ import { UserModule } from './user/user.module'; TagsModule, UserModule, WatchlistModule - ] + ], + providers: [I18nService] }) -export class AppModule {} +export class AppModule implements NestModule { + configure(consumer: MiddlewareConsumer) { + consumer.apply(HtmlTemplateMiddleware).forRoutes('*'); + } +} diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 73502525c..06138fecc 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -18,7 +18,6 @@ import helmet from 'helmet'; import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; -import { HtmlTemplateMiddleware } from './middlewares/html-template.middleware'; async function bootstrap() { const configApp = await NestFactory.create(AppModule); @@ -77,8 +76,6 @@ async function bootstrap() { }); } - app.use(HtmlTemplateMiddleware); - const HOST = configService.get('HOST') || DEFAULT_HOST; const PORT = configService.get('PORT') || DEFAULT_PORT;