-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (32 loc) · 1.31 KB
/
server.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
const express = require("express");
const mongoose = require("mongoose");
const cors = require("cors");
const bodyParser = require("body-parser");
const logger = require("morgan");
const memberRoutes = require("./routes/Member");
const destinationRoutes = require("./routes/Destination");
const transportRoutes = require("./routes/Transport");
const scheduleRoutes = require('./routes/Schedule');
const profileRoutes = require("./routes/Profile");
const formuleRoutes = require("./routes/Formule");
const carbonemissionRoutes = require("./routes/CarbonEmission");
const app = express();
const port = process.env.PORT || 3000;
//db
mongoose.connect( "mongodb+srv://racemhachicha1:[email protected]/impactProject")
.then(() => console.log(`DB CONNECTED`))
.catch((err) => console.log(`DB CONNECTION ERROR`, err));
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(logger("dev"));
app.use("/members", memberRoutes);
app.use("/destinations", destinationRoutes);
app.use("/transports", transportRoutes);
app.use("/schedule", scheduleRoutes);
app.use("/profiles",profileRoutes);
app.use("/formules",formuleRoutes);
app.use("/carbonemissions",carbonemissionRoutes);
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});