swag condition added

This commit is contained in:
Kallesh B S 2025-09-19 15:47:11 +05:30
parent c08b8bb19f
commit 3c27de26b9
3 changed files with 40 additions and 28 deletions

View File

@ -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);
}

View File

@ -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');
}
}

View File

@ -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');