generated from ibm-developer-skills-network/coding-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (28 loc) · 792 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Express app configuration
*/
const express = require('express');
const swaggerJsDoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');
// Create Express app
const app = express();
// Parse JSON request body
app.use(express.json());
// Swagger configuration
const swaggerOptions = {
definition: {
openapi: '3.0.0',
info: {
title: 'Hit Counter Service',
version: '0.0.1',
description: 'This service counts the number of hits to a URL',
},
},
apis: ['./routes/*.js'], // Path to the API routes
};
const swaggerDocs = swaggerJsDoc(swaggerOptions);
app.use('/', swaggerUi.serve, swaggerUi.setup(swaggerDocs));
// Load routes
const hitsRoutes = require('./routes/hits');
app.use('/hits', hitsRoutes);
module.exports = app;