-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (19 loc) · 733 Bytes
/
Copy pathapp.js
File metadata and controls
23 lines (19 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const express = require("express");
const bodyParser = require("body-parser");
const commonRoutes = require("./src/routes/common.routes");
const mongo = require("mongoose");
const usersRoute = require("./src/routes/user.routes");
const app = express();
const PORT = process.env.PORT || 7002;
app.use(bodyParser.json());
// prefix and add diffrent routes
app.use("/api", commonRoutes);
app.use("/api", usersRoute);
mongo.connect("mongodb://localhost:27017/common", { useNewUrlParser:true,
useUnifiedTopology:true,
useCreateIndex:true })
.then(res => console.log("DB connect succesfully"))
.catch(err => console.log("Can't connect to DB", err));
app.listen(PORT, () => {
console.log("Server connected");
});