-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (27 loc) · 867 Bytes
/
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
const express = require("express");
const mongoose = require("mongoose");
const userRouter = require('./app/routes/userRoutes');
const db = require('./app/config/db.config');
const app = express();
const authRoute = require('./app/routes/authRoute');
const panieRoute = require('./app/routes/panierRoute');
const commandeRoute = require('./app/routes/commandeRoute');
app.use(express.json());
mongoose.connect(db.url,{
useNewUrlParser: true,
useUnifiedTopology: true
}).then((e) => {
console.log("Connected to the database!");
})
.catch(err => {
console.log("Cannot connect to the database!", err);
process.exit();
});
app.use(userRouter);
app.use(authRoute);
app.use(panieRoute);
app.use(commandeRoute);
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});