-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (28 loc) · 780 Bytes
/
app.js
File metadata and controls
32 lines (28 loc) · 780 Bytes
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
const express = require("express");
const cors = require("cors");
const cookieParser = require("cookie-parser");
const mongoose = require("mongoose");
require("dotenv").config();
const router = require('./routes/mainRouter')
const apiErrorMiddleWare = require('./middleware/middlewareError')
const app = express();
app.use(express.json());
app.use(cookieParser());
app.use(cors());
app.use('/api' , router)
app.use(apiErrorMiddleWare)
const PORT = process.env.PORT || 3000;
const start = async () => {
try {
await mongoose.connect(process.env.DB_URL, {
useNewUrlParser: true,
//useUndefinedTopology: true
});
app.listen(PORT, () => {
console.log(`server is running on port ${PORT}`);
});
} catch (e) {
console.log(e);
}
};
start();