swag condition added
This commit is contained in:
parent
c08b8bb19f
commit
3c27de26b9
@ -105,7 +105,17 @@ export class AuthController {
|
|||||||
@Roles('sa')
|
@Roles('sa')
|
||||||
@Post('1/sendmail')
|
@Post('1/sendmail')
|
||||||
@HttpCode(200)
|
@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 })
|
// let token = await this.jwtService.generateToken({ email: mail })
|
||||||
return this.authService.sendMail(body);
|
return this.authService.sendMail(body);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export class OracleDBService {
|
|||||||
private readonly logger = new Logger(OracleDBService.name);
|
private readonly logger = new Logger(OracleDBService.name);
|
||||||
|
|
||||||
constructor(private readonly configService: ConfigService) {
|
constructor(private readonly configService: ConfigService) {
|
||||||
if (process.env.DB_FOR === "ORACLE") {
|
if (process.env.DB_TYPE === "ORACLE") {
|
||||||
this.initializePool().catch(err => {
|
this.initializePool().catch(err => {
|
||||||
this.logger.error('Error initializing Oracle DB pool', err);
|
this.logger.error('Error initializing Oracle DB pool', err);
|
||||||
throw new InternalServerException();
|
throw new InternalServerException();
|
||||||
@ -71,12 +71,13 @@ export class PgDBService implements OnModuleDestroy {
|
|||||||
private readonly logger = new Logger(PgDBService.name);
|
private readonly logger = new Logger(PgDBService.name);
|
||||||
|
|
||||||
constructor(private readonly configService: ConfigService) {
|
constructor(private readonly configService: ConfigService) {
|
||||||
if (process.env.DB_FOR === "PG") {
|
if (process.env.DB_TYPE === "PG") {
|
||||||
this.initializePool().catch(err => {
|
this.initializePool().catch(err => {
|
||||||
this.logger.error('Error initializing PostgreSQL DB pool', 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');
|
throw new InternalServerException('Failed to initialize database pool');
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.logger.warn('PG pool not initialized because DB_FOR is not PG');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
49
src/main.ts
49
src/main.ts
@ -16,7 +16,7 @@ async function bootstrap() {
|
|||||||
cors: {
|
cors: {
|
||||||
// origin: 'https://dev.alphaomegainfosys.com/',
|
// origin: 'https://dev.alphaomegainfosys.com/',
|
||||||
origin: [
|
origin: [
|
||||||
'http://localhost:3000',
|
'http://localhost:3000',
|
||||||
'http://localhost:5173',
|
'http://localhost:5173',
|
||||||
'https://policy.alphaomegainfosys.com',
|
'https://policy.alphaomegainfosys.com',
|
||||||
'https://sp.alphaomegainfosys.com',
|
'https://sp.alphaomegainfosys.com',
|
||||||
@ -81,27 +81,6 @@ async function bootstrap() {
|
|||||||
.setTitle('API')
|
.setTitle('API')
|
||||||
.setDescription('API description')
|
.setDescription('API description')
|
||||||
.setVersion('1.0')
|
.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(
|
.addServer(
|
||||||
'https://dev.alphaomegainfosys.com/test-api',
|
'https://dev.alphaomegainfosys.com/test-api',
|
||||||
'Development Server 2',
|
'Development Server 2',
|
||||||
@ -110,8 +89,30 @@ async function bootstrap() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
const options: SwaggerDocumentOptions = { autoTagControllers: false };
|
const options: SwaggerDocumentOptions = { autoTagControllers: false };
|
||||||
const documentFactory = () => SwaggerModule.createDocument(app, config, options);
|
// const documentFactory = () => SwaggerModule.createDocument(app, config, options);
|
||||||
SwaggerModule.setup('api', app, documentFactory);
|
// 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) => {
|
app.use('/api-json', (req, res) => {
|
||||||
res.setHeader('Content-Type', 'application/json');
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user