-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (29 loc) · 1.21 KB
/
server.js
File metadata and controls
42 lines (29 loc) · 1.21 KB
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
import express from "express";
import { db } from "./config/db.js";
import authRouter from "./routes/authRoute.js";
import userRouter from "./routes/userRoute.js"
import organisationRouter from "./routes/orgRoute.js";
import swaggerUI from "swagger-ui-express";
import swaggerDocs from "./swagger.json" assert { type: 'json' };
const appInit = () => {
const app = express()
// connect to db
db.authenticate()
.then(() => { console.log("database connection is succesful...")})
.catch((err) => { console.log(err)})
// middlewares
app.use(express.json())
const CSS_URL = "https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.1.0/swagger-ui.min.css"
app.use('/api-docs', swaggerUI.serve, swaggerUI.setup(swaggerDocs, {
customCss:
'.swagger-ui .opblock .opblock-summary-path-description-wrapper { align-items: center; display: flex; flex-wrap: wrap; gap: 0 10px; padding: 0 10px; width: 100%; }',
customCssUrl: CSS_URL,
}));
// routes
app.get("/", (req, res) => { res.json("you are welcome")})
app.use("/auth", authRouter)
app.use("/api", organisationRouter)
app.use("/api", userRouter)
return app
}
export const app = appInit()