-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (30 loc) · 1.08 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
const express = require("express");
const mongoose = require('mongoose');
const cors = require('cors')
const utilisateur_Routes = require('./routes/UilisateurRoutes/index');
const niveau_Routes= require('./routes/NiveauRoutes');
const absence_Routes = require('./routes/AbsenceRoutes');
const affectation_Routes = require('./routes/AffectationRoutes');
const stagiaire_Routes = require('./routes/StagiaireRoutes');
const filier_Routes = require('./routes/FilierRoutes');
const groupe_Routes = require('./routes/GroupeRoutes');
//set up express app
const app = express();
const port = 3001 || process.env.PORT
app.listen(port ,()=>{
console.log(`app connected to ${port}`);
});
//middleware
app.use(express.json());
app.use(cors())
//routes
const routes = [
utilisateur_Routes, niveau_Routes ,
absence_Routes , affectation_Routes ,
stagiaire_Routes , filier_Routes ,groupe_Routes
];
app.use(routes);
//connect to mongoDB
const url = "mongodb://localhost/GestionAbsence"
mongoose.connect(url,{ useNewUrlParser: true , useUnifiedTopology: true})
mongoose.Promise = global.Promise;