From a0e6f0e58bad7176512f5e447c64783713267efa Mon Sep 17 00:00:00 2001 From: Tiago Yamamoto Date: Mon, 15 Dec 2025 09:44:24 -0300 Subject: [PATCH] =?UTF-8?q?feat(swagger):=20=F0=9F=93=9A=20added=20Swagger?= =?UTF-8?q?=20docs=20at=20/api/docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backoffice/src/app.controller.ts | 12 ++++++++++++ backoffice/src/app.service.ts | 8 ++++++++ backoffice/src/main.ts | 26 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 backoffice/src/app.controller.ts create mode 100644 backoffice/src/app.service.ts create mode 100644 backoffice/src/main.ts diff --git a/backoffice/src/app.controller.ts b/backoffice/src/app.controller.ts new file mode 100644 index 0000000..cce879e --- /dev/null +++ b/backoffice/src/app.controller.ts @@ -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(); + } +} diff --git a/backoffice/src/app.service.ts b/backoffice/src/app.service.ts new file mode 100644 index 0000000..927d7cc --- /dev/null +++ b/backoffice/src/app.service.ts @@ -0,0 +1,8 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class AppService { + getHello(): string { + return 'Hello World!'; + } +} diff --git a/backoffice/src/main.ts b/backoffice/src/main.ts new file mode 100644 index 0000000..27de636 --- /dev/null +++ b/backoffice/src/main.ts @@ -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();