diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 5bd657d..9648bc7 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -105,7 +105,17 @@ export class AuthController { @Roles('sa') @Post('1/sendmail') @HttpCode(200) - async sendMail(@Body() body: SendMailDTO) { + async sendMaila(@Body() body: SendMailDTO) { + // let token = await this.jwtService.generateToken({ email: mail }) + return this.authService.sendMail(body); + } + + + @UseGuards(JwtAuthGuard, RolesGuard) + @Roles('sa') + @Post('2/sendmail') + @HttpCode(200) + async sendMailb(@Body() body: SendMailDTO) { // let token = await this.jwtService.generateToken({ email: mail }) return this.authService.sendMail(body); } diff --git a/src/db/db.service.ts b/src/db/db.service.ts index 87d3af3..958a804 100644 --- a/src/db/db.service.ts +++ b/src/db/db.service.ts @@ -12,7 +12,7 @@ export class OracleDBService { private readonly logger = new Logger(OracleDBService.name); constructor(private readonly configService: ConfigService) { - if (process.env.DB_FOR === "ORACLE") { + if (process.env.DB_TYPE === "ORACLE") { this.initializePool().catch(err => { this.logger.error('Error initializing Oracle DB pool', err); throw new InternalServerException(); @@ -71,12 +71,13 @@ export class PgDBService implements OnModuleDestroy { private readonly logger = new Logger(PgDBService.name); constructor(private readonly configService: ConfigService) { - if (process.env.DB_FOR === "PG") { + if (process.env.DB_TYPE === "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'); }); + } else { + this.logger.warn('PG pool not initialized because DB_FOR is not PG'); } } diff --git a/src/main.ts b/src/main.ts index f3da58a..e77df05 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,7 +16,7 @@ async function bootstrap() { cors: { // origin: 'https://dev.alphaomegainfosys.com/', origin: [ - 'http://localhost:3000', + 'http://localhost:3000', 'http://localhost:5173', 'https://policy.alphaomegainfosys.com', 'https://sp.alphaomegainfosys.com', @@ -81,27 +81,6 @@ async function bootstrap() { .setTitle('API') .setDescription('API description') .setVersion('1.0') - .addTag('Auth') - .addTag('Param Table - PG') - .addTag('Regions - PG') - .addTag('SP - PG') - .addTag('Carnet Sequence - PG') - .addTag('SPContacts - PG') - .addTag('User Maintenance - PG') - .addTag('Manage Fee - PG') - .addTag('Manage Holders - PG') - .addTag('Manage Clients - PG') - .addTag('User Maintenance - Oracle') - .addTag('Carnet Application - Oracle') - .addTag('HomePage - Oracle') - .addTag('Regions - Oracle') - .addTag('SP - Oracle') - .addTag('SPContacts - Oracle') - .addTag('Carnet Sequence - Oracle') - .addTag('Param Table - Oracle') - .addTag('Manage Fee - Oracle') - .addTag('Manage Holders - Oracle') - .addTag('Manage Clients - Oracle') .addServer( 'https://dev.alphaomegainfosys.com/test-api', 'Development Server 2', @@ -110,8 +89,30 @@ async function bootstrap() { .build(); const options: SwaggerDocumentOptions = { autoTagControllers: false }; - const documentFactory = () => SwaggerModule.createDocument(app, config, options); - SwaggerModule.setup('api', app, documentFactory); + // const documentFactory = () => SwaggerModule.createDocument(app, config, options); + // SwaggerModule.setup('api', app, documentFactory); + + const document = SwaggerModule.createDocument(app, config, options); + + // 2. Remove all paths starting with /1 or exactly /1 if not PG + if (process.env.DB_TYPE === 'PG') { + for (const path of Object.keys(document.paths)) { + if (path === '/1' || path.startsWith('/1/')) { + delete document.paths[path]; + } + } + } + + if (process.env.DB_TYPE === 'ORACLE') { + for (const path of Object.keys(document.paths)) { + if (path === '/2' || path.startsWith('/2/')) { + delete document.paths[path]; + } + } + } + + // 3. Setup Swagger with the modified document + SwaggerModule.setup('api', app, document); app.use('/api-json', (req, res) => { res.setHeader('Content-Type', 'application/json');