diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 17f8996..5bd657d 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -55,7 +55,7 @@ export class AuthController { @UseInterceptors(LogoutInterceptor) @HttpCode(200) - @Post('logout') + @Post('1/logout') async logout(@Req() req: any, @Res() res: Response) { const refreshToken = req.user?.refreshToken; let rst: any = await this.authService.logoutUser(refreshToken); @@ -74,7 +74,7 @@ export class AuthController { res.json({ ...rst }) } - @Get('refresh-tokens') + @Get('1/refresh-tokens') async getTokenFromRefreshToken(@Req() req: Request, @Res({ passthrough: true }) res: Response) { let k: any = await this.authService.getTokenFromRefreshToken(req) @@ -103,7 +103,7 @@ export class AuthController { @UseGuards(JwtAuthGuard, RolesGuard) @Roles('sa') - @Post('sendmail') + @Post('1/sendmail') @HttpCode(200) async sendMail(@Body() body: SendMailDTO) { // let token = await this.jwtService.generateToken({ email: mail }) diff --git a/src/db/db.service.ts b/src/db/db.service.ts index fc40b2c..87d3af3 100644 --- a/src/db/db.service.ts +++ b/src/db/db.service.ts @@ -12,10 +12,12 @@ export class OracleDBService { private readonly logger = new Logger(OracleDBService.name); constructor(private readonly configService: ConfigService) { - this.initializePool().catch(err => { - this.logger.error('Error initializing Oracle DB pool', err); - throw new InternalServerException(); - }); + if (process.env.DB_FOR === "ORACLE") { + this.initializePool().catch(err => { + this.logger.error('Error initializing Oracle DB pool', err); + throw new InternalServerException(); + }); + } } private async initializePool(): Promise { @@ -63,54 +65,19 @@ export class OracleDBService { } } - -@Injectable() -export class MssqlDBService { - private pool: ConnectionPool; - private poolConnected = false; - - constructor(private readonly configService: ConfigService) { - const config: any = getMssqlConfig(configService); - this.pool = new ConnectionPool({ - ...config, - pool: { - max: 10, - min: 0, - idleTimeoutMillis: 30000, - }, - }); - } - - async getConnection(): Promise { - try { - if (!this.poolConnected) { - this.pool.on('error', err => { - console.error('SQL Pool Error:', err); - this.poolConnected = false; - }); - - await this.pool.connect(); - this.poolConnected = true; - } - return this.pool; - } catch (error) { - console.error('Failed to get connection from pool:', error); - throw error; - } - } -} - @Injectable() export class PgDBService implements OnModuleDestroy { private pool: pgPool | null = null; private readonly logger = new Logger(PgDBService.name); constructor(private readonly configService: ConfigService) { - this.initializePool().catch(err => { - this.logger.error('Error initializing PostgreSQL DB pool', err); - // Re-throw to indicate a critical startup failure, preventing the application from starting - throw new InternalServerException('Failed to initialize database pool'); - }); + if (process.env.DB_FOR === "PG") { + this.initializePool().catch(err => { + this.logger.error('Error initializing PostgreSQL DB pool', err); + // Re-throw to indicate a critical startup failure, preventing the application from starting + throw new InternalServerException('Failed to initialize database pool'); + }); + } } /** @@ -199,4 +166,40 @@ export class PgDBService implements OnModuleDestroy { } } } -} \ No newline at end of file +} + +@Injectable() +export class MssqlDBService { + private pool: ConnectionPool; + private poolConnected = false; + + constructor(private readonly configService: ConfigService) { + const config: any = getMssqlConfig(configService); + this.pool = new ConnectionPool({ + ...config, + pool: { + max: 10, + min: 0, + idleTimeoutMillis: 30000, + }, + }); + } + + async getConnection(): Promise { + try { + if (!this.poolConnected) { + this.pool.on('error', err => { + console.error('SQL Pool Error:', err); + this.poolConnected = false; + }); + + await this.pool.connect(); + this.poolConnected = true; + } + return this.pool; + } catch (error) { + console.error('Failed to get connection from pool:', error); + throw error; + } + } +} diff --git a/src/pg/manage-clients/manage-clients.controller.ts b/src/pg/manage-clients/manage-clients.controller.ts index c20ef13..3da1426 100644 --- a/src/pg/manage-clients/manage-clients.controller.ts +++ b/src/pg/manage-clients/manage-clients.controller.ts @@ -9,7 +9,7 @@ import { RolesGuard } from 'src/guards/roles.guard'; @ApiTags('Manage Clients - PG') // @UseGuards(JwtAuthGuard, RolesGuard) @Roles('sa') -@Controller('1') +@Controller('2') export class ManageClientsController { constructor(private readonly manageClientsService: ManageClientsService) { } diff --git a/src/pg/manage-holder/manage-holder.controller.ts b/src/pg/manage-holder/manage-holder.controller.ts index 4a8517a..fc4ca38 100644 --- a/src/pg/manage-holder/manage-holder.controller.ts +++ b/src/pg/manage-holder/manage-holder.controller.ts @@ -10,7 +10,7 @@ import { RolesGuard } from 'src/guards/roles.guard'; @ApiTags('Manage Holders - PG') // @UseGuards(JwtAuthGuard, RolesGuard) @Roles('ca', 'sa') -@Controller('manage-holder') +@Controller('2') export class ManageHolderController { constructor(private readonly manageHoldersService: ManageHolderService) { }