-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (40 loc) · 1.13 KB
/
index.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const express = require("express");
const jwt = require("jsonwebtoken");
const cors = require("cors");
const swaggerJsDoc = require("swagger-jsdoc");
const swaggerUI = require("swagger-ui-express");
const options = {
definition: {
openapi: "3.0.0",
info: {
title: "Authentication & User API",
version: "0.0.1",
description: "Details on the API for authentication and user operations",
},
servers: [
{
url: "http://localhost:5000",
},
],
},
apis: ["./apps/routes/*.js"],
};
const specs = swaggerJsDoc(options);
const app = express();
const PORT = 5000;
app.use(
cors({
origin: "*",
methods: "*",
})
);
app.use("/api-docs", swaggerUI.serve, swaggerUI.setup(specs));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
require("./apps/routes/user.routes")(app, express);
require("./apps/routes/auth.routes")(app, express);
require("./apps/routes/test.routes")(app, express);
// require("./apps/routes/api-docs.routes")(app, express);
const server = app.listen(PORT);
console.log(`Server started at port ${PORT}`);
module.exports = { app, server };