diff --git a/docsfera.json b/docsfera.json index c22abaf..73ff0ac 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3257,7 +3257,7 @@ "info": { "title": "Maestro", "description": "Documentation for Maestro gateway", - "version": "9.11.2022 - 11:27", + "version": "feat/rest-api", "contact": {} }, "tags": [], diff --git a/src/main.ts b/src/main.ts index a0debd5..83d438a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { AppModule } from './app.module'; import { writeFile, writeFileSync } from 'fs'; +import { exec, ExecException, execSync } from 'child_process'; async function bootstrap() { DadosferaLogger.setupLogger({ serviceName: 'maestro', @@ -26,15 +27,23 @@ async function bootstrap() { app.use(helmet()); const date = new Date(); + let swaggerVersion = `${date.getDate()}.${ + date.getMonth() + 1 + }.${date.getFullYear()} - ${date.getHours()}:${date.getMinutes()}`; + + try { + const branchName = execSync('git rev-parse --abbrev-ref HEAD') + .toString() + .replace('\n', ''); + swaggerVersion = branchName; + } catch (error) { + console.log("Can't get branch name", error); + } const config = new DocumentBuilder() .setTitle('Maestro') .setDescription('Documentation for Maestro gateway') - .setVersion( - `${date.getDate()}.${ - date.getMonth() + 1 - }.${date.getFullYear()} - ${date.getHours()}:${date.getMinutes()}`, - ) + .setVersion(swaggerVersion) .addBearerAuth( { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' }, 'Authorization',