-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (30 loc) · 949 Bytes
/
index.js
File metadata and controls
36 lines (30 loc) · 949 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 app = express()
const usersRoutes = require("./routes/users.route");
const postsRoutes = require("./routes/posts.route");
app.use(express.json())
const swaggerJsdoc = require("swagger-jsdoc");
const swaggerUi = require("swagger-ui-express");
/** Swagger Initialization - START */
const swaggerOption = {
swaggerDefinition: (swaggerJsdoc.Options = {
info: {
title: "my-community",
description: "API documentation",
contact: {
name: "Ridwan",
},
servers: ["http://localhost:4000/"],
},
}),
apis: ["index.js", "./routes/*.js"],
};
const swaggerDocs = swaggerJsdoc(swaggerOption);
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocs));
/** Swagger Initialization - END */
app.get('/', (req, res) => {
res.send("listening")
})
app.use("/users", usersRoutes);
app.use("/posts", postsRoutes);
app.listen(4000)