Skip to content

Commit

Permalink
Update: Added nodemon and SwaggerJS
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangsonww committed Oct 22, 2024
1 parent cd349c1 commit cb981c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions backend/docs/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
5 changes: 4 additions & 1 deletion backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit cb981c6

Please sign in to comment.