Initial commit
This commit is contained in:
112
src/main.ts
Executable file
112
src/main.ts
Executable file
@@ -0,0 +1,112 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { ValidationPipe, VersioningType } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
// No SSL - nginx lo maneja
|
||||
const app = await NestFactory.create(AppModule);
|
||||
const configService = app.get(ConfigService);
|
||||
|
||||
// Enable CORS
|
||||
app.enableCors({
|
||||
origin: (origin, callback) => {
|
||||
callback(null, true);
|
||||
},
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
||||
allowedHeaders: ['Content-Type', 'Authorization', 'Accept', 'X-Requested-With', 'Origin'],
|
||||
credentials: true,
|
||||
preflightContinue: false,
|
||||
optionsSuccessStatus: 204,
|
||||
exposedHeaders: ['Set-Cookie']
|
||||
});
|
||||
|
||||
// Global prefix
|
||||
app.setGlobalPrefix('api');
|
||||
|
||||
// API Versioning
|
||||
app.enableVersioning({
|
||||
type: VersioningType.URI,
|
||||
defaultVersion: '1',
|
||||
});
|
||||
|
||||
// Global validation pipe
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
whitelist: true,
|
||||
forbidNonWhitelisted: true,
|
||||
transform: true,
|
||||
transformOptions: {
|
||||
enableImplicitConversion: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
// Swagger Documentation
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle(configService.get<string>('app.name') || 'Karibeo API')
|
||||
.setDescription(configService.get<string>('app.description') || 'Tourism API')
|
||||
.setVersion(configService.get<string>('app.version') || '1.0.0')
|
||||
.addBearerAuth(
|
||||
{
|
||||
type: 'http',
|
||||
scheme: 'bearer',
|
||||
bearerFormat: 'JWT',
|
||||
name: 'JWT',
|
||||
description: 'Enter JWT token',
|
||||
in: 'header',
|
||||
},
|
||||
'JWT-auth',
|
||||
)
|
||||
.addTag('Authentication', 'User authentication and authorization')
|
||||
.addTag('Users', 'User management operations')
|
||||
.addTag('Tourism', 'Tourism-related operations')
|
||||
.addTag('Commerce', 'Commerce and booking operations')
|
||||
.addTag('Security', 'Security and emergency operations')
|
||||
.addTag('Analytics', 'Analytics and metrics')
|
||||
.addTag('Notifications', 'Push, Email, and WhatsApp notifications')
|
||||
.addTag('Payments', 'Payment processing and transactions (Stripe)')
|
||||
.addTag('Upload', 'File upload to AWS S3')
|
||||
.addTag('Communication', 'Email and WhatsApp messaging')
|
||||
.addTag('Restaurant', 'Restaurant Point of Sale (POS) system')
|
||||
.addTag('Hotel', 'Hotel management (Rooms, Check-ins, Room Service)')
|
||||
.addTag('AI Guide', 'AI-powered virtual tour guide and AR content')
|
||||
.addTag('Geolocation', 'Location tracking, geofencing, smart navigation')
|
||||
.addTag('Channel Management', 'Management of external distribution channels (OTAs)')
|
||||
.addTag('Listings Management', 'Management of properties and tourism resources (hotels, vehicles, etc.)')
|
||||
.addTag('Vehicle Management', 'Management and availability of rental vehicles')
|
||||
.addTag('Flight Management', 'Flight search and booking operations')
|
||||
.addTag('Availability Management', 'Generic availability management for all resources')
|
||||
.addTag('Reviews', 'Advanced user reviews with multimedia and sentiment analysis')
|
||||
.addTag('AI Generator', 'Generative AI content creation')
|
||||
.addTag('Personalization', 'User experience personalization')
|
||||
.addTag('Sustainability', 'Sustainable tourism tracking and eco-certifications')
|
||||
.addTag('Social Commerce', 'Influencer marketing and UGC management')
|
||||
.addTag('IoT Tourism', 'IoT device integration and smart tourism data')
|
||||
.addTag('Finance', 'Commission rates, admin transactions, and settlements')
|
||||
.addServer('https://karibeo.lesoluciones.net:8443', 'Production HTTPS')
|
||||
.addServer('http://localhost:3000', 'Local development')
|
||||
.build();
|
||||
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup('api/docs', app, document, {
|
||||
customSiteTitle: 'Karibeo API Documentation',
|
||||
customfavIcon: '/favicon.ico',
|
||||
customCssUrl: '/swagger-ui.css',
|
||||
swaggerOptions: {
|
||||
persistAuthorization: true,
|
||||
displayRequestDuration: true,
|
||||
},
|
||||
});
|
||||
|
||||
// Siempre puerto 3000 HTTP - nginx maneja SSL
|
||||
const port = process.env.PORT || 3000;
|
||||
await app.listen(port);
|
||||
|
||||
console.log(`Karibeo API is running on: http://localhost:${port}`);
|
||||
console.log(`API Documentation: http://localhost:${port}/api/docs`);
|
||||
console.log(`External access: https://karibeo.lesoluciones.net:8443`);
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
Reference in New Issue
Block a user