From 2097b275cc82f1a7349e8275d8b0669156ab974b Mon Sep 17 00:00:00 2001 From: SennayT Date: Tue, 19 May 2026 09:40:08 +0300 Subject: [PATCH] remove localhost on swagger --- apps/edr-passenger-api/src/main.ts | 77 ++++++++++++++++-------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/apps/edr-passenger-api/src/main.ts b/apps/edr-passenger-api/src/main.ts index 71de72738..c0ca48097 100644 --- a/apps/edr-passenger-api/src/main.ts +++ b/apps/edr-passenger-api/src/main.ts @@ -1,18 +1,18 @@ -import 'reflect-metadata'; -import { NestFactory } from '@nestjs/core'; -import { ValidationPipe } from '@nestjs/common'; -import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; -import { AppModule } from './app.module'; -import { HttpExceptionFilter } from './common/filters/http-exception.filter'; -import { ResponseTransformInterceptor } from './common/interceptors/response-transform.interceptor'; +import "reflect-metadata"; +import { NestFactory } from "@nestjs/core"; +import { ValidationPipe } from "@nestjs/common"; +import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger"; +import { AppModule } from "./app.module"; +import { HttpExceptionFilter } from "./common/filters/http-exception.filter"; +import { ResponseTransformInterceptor } from "./common/interceptors/response-transform.interceptor"; async function bootstrap() { const app = await NestFactory.create(AppModule); app.enableCors({ origin: [ - process.env.FRONTEND_URL ?? 'http://localhost:3000', - process.env.PORTAL_URL ?? 'http://localhost:3001', + process.env.FRONTEND_URL ?? "http://localhost:3000", + process.env.PORTAL_URL ?? "http://localhost:3001", ], }); @@ -21,37 +21,44 @@ async function bootstrap() { app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true })); const config = new DocumentBuilder() - .setTitle('EDR Passenger API') + .setTitle("EDR Passenger API") .setDescription( - 'Ethio-Djibouti Railway Passenger API — booking lifecycle, seat inventory, payment (Telebirr, CBE Birr, eBirr, Card, Wallet), loyalty, live tracking, and support.', + "Ethio-Djibouti Railway Passenger API — booking lifecycle, seat inventory, payment (Telebirr, CBE Birr, eBirr, Card, Wallet), loyalty, live tracking, and support.", ) - .setVersion('1.0.0') - .addBearerAuth({ type: 'http', scheme: 'bearer', bearerFormat: 'JWT', in: 'header' }, 'JWT-auth') - .addTag('Auth', 'Registration and login') - .addTag('Stations', 'Station directory') - .addTag('Fleet', 'Train services and coaches') - .addTag('Schedule', 'Trips and fare rules') - .addTag('Search', 'Trip search and fare quotes') - .addTag('Seats', 'Seat maps and holds') - .addTag('Booking', 'Booking lifecycle') - .addTag('Payment', 'Payment intents and refunds') - .addTag('Tickets', 'QR ticket generation and validation') - .addTag('Passenger', 'Profiles, traveler profiles, saved routes') - .addTag('Notifications', 'Push and email notifications') - .addTag('Loyalty', 'Points, tiers, and rewards') - .addTag('Wallet', 'Wallet balance and ledger') - .addTag('Promotions', 'Promo codes and campaigns') - .addTag('Live Tracking', 'Real-time trip status and crowd signals') - .addTag('Support', 'FAQ and chat support') - .addTag('Dashboard', 'Home dashboard aggregate') - .addServer('http://localhost:4000', 'Development') - .addServer('https://api.edr-platform.com', 'Production') + .setVersion("1.0.0") + .addBearerAuth( + { type: "http", scheme: "bearer", bearerFormat: "JWT", in: "header" }, + "JWT-auth", + ) + .addTag("Auth", "Registration and login") + .addTag("Stations", "Station directory") + .addTag("Fleet", "Train services and coaches") + .addTag("Schedule", "Trips and fare rules") + .addTag("Search", "Trip search and fare quotes") + .addTag("Seats", "Seat maps and holds") + .addTag("Booking", "Booking lifecycle") + .addTag("Payment", "Payment intents and refunds") + .addTag("Tickets", "QR ticket generation and validation") + .addTag("Passenger", "Profiles, traveler profiles, saved routes") + .addTag("Notifications", "Push and email notifications") + .addTag("Loyalty", "Points, tiers, and rewards") + .addTag("Wallet", "Wallet balance and ledger") + .addTag("Promotions", "Promo codes and campaigns") + .addTag("Live Tracking", "Real-time trip status and crowd signals") + .addTag("Support", "FAQ and chat support") + .addTag("Dashboard", "Home dashboard aggregate") + //.addServer('http://localhost:4000', 'Development') + // .addServer("https://api.edr-platform.com", "Production") .build(); const document = SwaggerModule.createDocument(app, config); - SwaggerModule.setup('api-docs', app, document, { - customSiteTitle: 'EDR Passenger API', - swaggerOptions: { persistAuthorization: true, docExpansion: 'none', filter: true }, + SwaggerModule.setup("api-docs", app, document, { + customSiteTitle: "EDR Passenger API", + swaggerOptions: { + persistAuthorization: true, + docExpansion: "none", + filter: true, + }, }); const port = process.env.PORT ?? 4000;