Initial commit of edr-passenger-api alpha version

This commit is contained in:
Stephanos A
2026-05-13 16:58:49 +03:00
parent 199a3eba11
commit 39ba561d8f
113 changed files with 3602 additions and 1035 deletions

View File

@@ -1,35 +1,62 @@
import "reflect-metadata";
import { NestFactory } from "@nestjs/core";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import {
HttpExceptionFilter,
ResponseTransformInterceptor,
createValidationPipe,
} from "@edr/api-common";
import { AppModule } from "./app.module";
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, { cors: true });
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: [
process.env.FRONTEND_URL ?? 'http://localhost:3000',
process.env.PORTAL_URL ?? 'http://localhost:3001',
],
});
app.setGlobalPrefix("api");
app.useGlobalPipes(createValidationPipe());
app.useGlobalFilters(new HttpExceptionFilter());
app.useGlobalInterceptors(new ResponseTransformInterceptor());
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
const config = new DocumentBuilder()
.setTitle("EDR Passenger API")
.setDescription("API for the EDR Passenger Management application")
.setVersion("0.1.0")
.addBearerAuth()
.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.',
)
.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);
SwaggerModule.setup('api-docs', app, document, {
customSiteTitle: 'EDR Passenger API',
swaggerOptions: { persistAuthorization: true, docExpansion: 'none', filter: true },
});
const port = parseInt(process.env.PORT ?? "3002", 10);
const port = process.env.PORT ?? 4000;
await app.listen(port);
// eslint-disable-next-line no-console
console.log(`[passenger-api] listening on http://localhost:${port}`);
console.log(`🚀 EDR Passenger API running on port ${port}`);
console.log(`📚 Swagger: http://localhost:${port}/api-docs`);
}
bootstrap();