feat(api): add OpenAPI/Swagger documentation for all API endpoints
Install @nestjs/swagger, configure Swagger UI at /api/docs with JWT bearer auth, and add ApiTags/ApiOperation/ApiResponse/ApiProperty decorators to all 8 controllers (50+ endpoints) and 31 DTOs across auth, listings, search, payments, subscriptions, admin, notifications, and analytics modules. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { LoggerService } from '@modules/shared';
|
||||
import helmet from 'helmet';
|
||||
import { AppModule } from './app.module';
|
||||
@@ -9,17 +10,40 @@ async function bootstrap() {
|
||||
const logger = app.get(LoggerService);
|
||||
app.useLogger(logger);
|
||||
|
||||
// ── OpenAPI / Swagger ──
|
||||
const swaggerConfig = new DocumentBuilder()
|
||||
.setTitle('Goodgo Platform API')
|
||||
.setDescription('Real-estate platform API — listings, search, payments, subscriptions, analytics')
|
||||
.setVersion('1.0')
|
||||
.addBearerAuth(
|
||||
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
|
||||
'JWT',
|
||||
)
|
||||
.addTag('auth', 'Authentication & user profile')
|
||||
.addTag('listings', 'Property listings CRUD & moderation')
|
||||
.addTag('search', 'Full-text & geo search')
|
||||
.addTag('payments', 'Payment processing & callbacks')
|
||||
.addTag('subscriptions', 'Plans, billing & usage metering')
|
||||
.addTag('admin', 'Admin panel operations')
|
||||
.addTag('notifications', 'Notification history & preferences')
|
||||
.addTag('analytics', 'Market reports & price analytics')
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, swaggerConfig);
|
||||
SwaggerModule.setup('api/docs', app, document, {
|
||||
swaggerOptions: { persistAuthorization: true },
|
||||
});
|
||||
|
||||
// ── Security Headers (Helmet) ──
|
||||
app.use(
|
||||
helmet({
|
||||
contentSecurityPolicy: {
|
||||
directives: {
|
||||
defaultSrc: ["'self'"],
|
||||
scriptSrc: ["'self'"],
|
||||
scriptSrc: ["'self'", "'unsafe-inline'"],
|
||||
styleSrc: ["'self'", "'unsafe-inline'"],
|
||||
imgSrc: ["'self'", 'data:', 'https:'],
|
||||
imgSrc: ["'self'", 'data:', 'https:', 'blob:'],
|
||||
connectSrc: ["'self'"],
|
||||
fontSrc: ["'self'"],
|
||||
fontSrc: ["'self'", 'data:'],
|
||||
objectSrc: ["'none'"],
|
||||
frameSrc: ["'none'"],
|
||||
baseUri: ["'self'"],
|
||||
|
||||
Reference in New Issue
Block a user