-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (39 loc) · 1.04 KB
/
app.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
const express = require("express");
const app = express();
app.use(express.json());
const cors = require("cors");
const mongoose = require("mongoose");
const profile = require("./routes/routes");
const swaggerUi = require("swagger-ui-express");
const yamljs = require("yamljs");
const swaggerDocs = yamljs.load("./swagger.yaml");
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocs));
mongoose.connect(
"",
{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: true,
},
() => {
console.log(`connected to mongoDB atlas`);
}
);
// mongoose.connect(
// "mongodb://localhost:27017/HackRx2",
// { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify:true },
// () => {
// console.log("connected to mongoDB local");
// }
// );
app.use(cors());
app.get("/", (req, res) => {
res.send("hello aws");
});
//routes
app.use("/api/", profile);
const PORT = 3500;
app.listen(PORT, () => {
console.log(`server started at port : ${PORT}`);
});