diff --git a/backend/docs/swagger.js b/backend/docs/swagger.js index 221905c..7f3342e 100644 --- a/backend/docs/swagger.js +++ b/backend/docs/swagger.js @@ -148,7 +148,14 @@ const options = { // Initialize swagger-jsdoc const swaggerSpec = swaggerJSDoc(options); +const setupSwaggerUi = (app) => { + app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec, { + customSiteTitle: 'Fusion E-Commerce API Docs', // Customize the browser tab title + })); +}; + module.exports = { swaggerUi, swaggerSpec, + setupSwaggerUi, }; diff --git a/backend/index.js b/backend/index.js index 7319f9a..6c7841d 100644 --- a/backend/index.js +++ b/backend/index.js @@ -8,7 +8,7 @@ const seedDB = require('./seed/productSeeds'); const productRoutes = require('./routes/products'); const checkoutRoutes = require('./routes/checkout'); const authRoutes = require('./routes/auth'); -const { swaggerUi, swaggerSpec } = require('./docs/swagger'); +const { swaggerUi, swaggerSpec, setupSwaggerUi } = require('./docs/swagger'); // Create Express App const app = express(); @@ -30,6 +30,9 @@ app.get('/', (req, res) => { res.redirect('/api-docs'); }); +// Setup Swagger UI with customized title +setupSwaggerUi(app); + // Routes app.use('/api/products', productRoutes); app.use('/api/checkout', checkoutRoutes);