-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (30 loc) · 963 Bytes
/
index.js
File metadata and controls
36 lines (30 loc) · 963 Bytes
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
35
36
const express = require("express");
const swaggerJsdoc = require("swagger-jsdoc");
const swaggerUi = require("swagger-ui-express");
const app = express();
const bodyParser = require("body-parser");
const usersRoutes = require("./routes/users.route");
const postsRoutes = require("./routes/posts.route");
app.use(bodyParser.json());
/** Swagger Initialization - START*/
const swaggerOption = {
swaggerDefinition: (swaggerJsdoc.Options = {
info: {
title: "my-posts",
description: "API documentation",
contact: {
name: "Developer",
},
servers: ["http://localhost:3000/"],
},
}),
apis: ["index.js", "./routes/*.js"],
};
const swaggerDocs = swaggerJsdoc(swaggerOption);
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocs));
/** Swagger Initialization - END*/
app.use("/users", usersRoutes);
app.use("/posts", postsRoutes);
app.listen(3000, () => {
console.log("I am ready to listen you");
});