forked from aqsaqayyum123/Bookkeeping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
54 lines (42 loc) · 1.09 KB
/
app.ts
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
50
51
52
53
54
import express from "express";
import db from "./config/database";
import indexRoutes from "./routes";
import dotenv from "dotenv";
dotenv.config();
import swaggerJSDoc from "swagger-jsdoc";
import swaggerUI from "swagger-ui-express";
const swaggerOptions = {
swaggerDefinition: {
info: {
title: "Backend APIS",
description: "API'S Information in detail",
version: "1.0.0",
contact: {
name: "Developer",
},
servers: ["http://localhost:5000"],
},
},
apis: ["./routes/api/*.routes.ts"],
};
const app = express();
app.use(indexRoutes);
const swaggerDocs = swaggerJSDoc(swaggerOptions);
app.use("/bookkeeping", swaggerUI.serve, swaggerUI.setup(swaggerDocs));
async function dbconnection() {
try {
let result = await db.authenticate();
console.log(" Database connected successfully");
} catch (error) {
console.log(error);
}
}
dbconnection();
app.get("/", (req, res) => res.send("index"));
try {
const PORT = process.env.PORT || 3001;
app.listen(PORT);
console.log(`listening on ${PORT}`);
} catch (error) {
console.log(error);
}