refactor: ( passenger-api.auth ) remove the existing auth module

This commit is contained in:
Abubeker Yasin
2026-06-03 10:12:08 +03:00
parent 092199f536
commit 785623fcbb
9 changed files with 209 additions and 115 deletions

View File

@@ -1,4 +1,9 @@
import { Module, NestModule, MiddlewareConsumer } from '@nestjs/common';
import {
MiddlewareConsumer,
Module,
NestModule,
OnApplicationBootstrap,
} from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ScheduleModule } from '@nestjs/schedule';
import { EventEmitterModule } from '@nestjs/event-emitter';
@@ -6,6 +11,7 @@ import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
// Subpath import: the @tria-plc/iamapi-common barrel does not resolve under moduleResolution:"Node".
// Aliased to avoid clashing with the app's existing custom ./common/iam.module (remote IamGuard).
import { IamModule as TriaIamModule } from '@tria-plc/iamapi-common/iam.module';
import { DataSeeder } from '@tria-plc/iamapi-common/db/seed/seeder';
import { PrismaModule } from './common/prisma.module';
import { I18nModule } from './common/i18n/i18n.module';
import { LocaleMiddleware } from './common/i18n/locale.middleware';
@@ -18,7 +24,6 @@ import ebirrConfig from './config/ebirr.config';
import cardConfig from './config/card.config';
import waafiConfig from './config/waafi.config';
import faydaConfig from './config/fayda.config';
import { AuthModule } from './modules/auth/auth.module';
import { StationsModule } from './modules/stations/stations.module';
import { FleetModule } from './modules/fleet/fleet.module';
import { SchedulesModule } from './modules/schedules/schedules.module';
@@ -61,22 +66,14 @@ import { VerifaydaModule } from './modules/verifayda/verifayda.module';
}),
ScheduleModule.forRoot(),
EventEmitterModule.forRoot(),
// TypeORM root DataSource for the shared `iam` schema (coexists with Prisma's `passenger`
// schema). Required so @tria-plc/api-common's JwtGuard can read `iam.sessions`, and so
// IamModule's forFeature repositories resolve. Options come from the `database` config
// namespace (see config/database.config.ts → iam-typeorm.config.ts).
TypeOrmModule.forRootAsync({
inject: [ConfigService],
useFactory: (config: ConfigService): TypeOrmModuleOptions =>
config.get<TypeOrmModuleOptions>('iamDatabase')!,
}),
// Mount the @tria-plc IAM module (auth/user/org-structure). Registers the IAM REST API under
// /v1/* (URI versioning). NOTE: SharedAuthModule (global JwtGuard) is intentionally added later
// in the route-protection phase, so public passenger routes are not 401'd before then.
TriaIamModule.forRoot(),
PrismaModule,
I18nModule,
// AuthModule,
StationsModule,
FleetModule,
SchedulesModule,
@@ -102,8 +99,16 @@ import { VerifaydaModule } from './modules/verifayda/verifayda.module';
VerifaydaModule,
],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(LocaleMiddleware).forRoutes('*');
export class AppModule implements OnApplicationBootstrap {
constructor(
private readonly seeder: DataSeeder,
// private readonly edrOrgSeeder: EdrOrgSeeder,
// private readonly demoUsersSeeder: DemoUsersSeeder,
) { }
async onApplicationBootstrap() {
await this.seeder.run();
// await this.edrOrgSeeder.run();
// await this.demoUsersSeeder.run();
}
}