-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (21 loc) · 893 Bytes
/
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
import dotenv from "dotenv"
import express from "express"
import cors from "cors"
import bodyParser from "body-parser"
import swaggerUiExpress from "swagger-ui-express"
import swaggerFile from "./swagger_output.json" assert { type: "json" }
import connectToDatabase from "./configs/database-connect.js"
import router from "./routes/index.js"
dotenv.config()
connectToDatabase()
const app = express()
app.use(cors())
app.use(bodyParser.json({ limit: "16mb" }))
app.use(bodyParser.urlencoded({ extended: true, limit: "50mb" }))
app.use("/api", router)
// * ref: https://dev.to/luizcalaca/autogenerated-documentation-api-with-openapi-and-swagger-for-nodejs-and-express-31g9
app.use("/doc", swaggerUiExpress.serve, swaggerUiExpress.setup(swaggerFile))
const port = process.env.PORT || 3000
app.listen(port, function callback() {
console.log(`EXPRESS connected to port ${port}!`)
})