feat(swagger): 📚 added Swagger docs at /api/docs

This commit is contained in:
Tiago Yamamoto 2025-12-15 09:44:24 -03:00
parent 9b8d1e0458
commit a0e6f0e58b
3 changed files with 46 additions and 0 deletions

View file

@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}

View file

@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}

26
backoffice/src/main.ts Normal file
View file

@ -0,0 +1,26 @@
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule, { rawBody: true });
app.enableCors({ origin: ['http://localhost:3000', 'https://gohorsejobs.com'], credentials: true });
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
const config = new DocumentBuilder()
.setTitle('GoHorse Backoffice API')
.setDescription('SaaS Administration and Subscription Management')
.setVersion('1.0')
.addTag('Stripe').addTag('Plans').addTag('Admin Dashboard')
.addBearerAuth()
.build();
SwaggerModule.setup('api/docs', app, SwaggerModule.createDocument(app, config));
const port = process.env.PORT || 3001;
await app.listen(port);
console.log(`🚀 Backoffice API: http://localhost:${port}`);
console.log(`📚 Swagger docs: http://localhost:${port}/api/docs`);
}
bootstrap();