From 6f57a4455ea1a472eb74b5cca635c3fe4b5bcf90 Mon Sep 17 00:00:00 2001 From: Anurag Sahu Date: Sat, 27 Dec 2025 20:53:38 +0530 Subject: [PATCH] feat: update swagger --- src/swagger.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/swagger.ts b/src/swagger.ts index 60d780d..9ed2055 100644 --- a/src/swagger.ts +++ b/src/swagger.ts @@ -4,6 +4,9 @@ import { Router, Request, Response, NextFunction } from "express"; import { config } from "./config/config"; import path from "node:path"; +const isProduction = config.server.nodeEnv === "production"; +const basePath = isProduction ? path.join(__dirname, "./routes/*.ts") : path.join(__dirname, "./routes/*.js"); + const options: swaggerJsdoc.Options = { definition: { openapi: "3.0.0", @@ -19,13 +22,9 @@ const options: swaggerJsdoc.Options = { }, servers: [ { - url: `http://localhost:${config.server.port}`, - description: "Local development server", - }, - { - url: "https://api.yourproduction.com", - description: "Production server", - }, + url: "/api/v1", + description: "API v1", + } ], components: { securitySchemes: { @@ -49,8 +48,7 @@ const options: swaggerJsdoc.Options = { }, // Path to the API routes files where JSDoc comments are apis: [ - path.join(__dirname, "./routes/*.ts"), - path.join(__dirname, "./routes/*.js"), + basePath, ], };