-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
48 lines (40 loc) · 1.17 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
40
41
42
43
44
45
46
47
48
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const cors = require('cors');
const PORT = '3000';
require('dotenv/config');
const passport = require('passport');
// require('./config/database');
// require('./config/passport')(passport);
// app.use(passport.initialize());
// Middlewares
app.use(cors());
app.use(express.json());
app.use(
express.urlencoded({
extended: true,
}),
);
// Importation des Routes
const userRoute = require('./routes/user');
const memoRoute = require('./routes/memo');
const postitRoute = require('./routes/postit');
// Gestion des routes par le Middleware
app.use('/user', userRoute);
app.use('/memo', memoRoute);
app.use('/postit', postitRoute);
// Routes
app.get('/', async (req, res) => {
res.send('Nous sommes dans la HomePage');
});
// Connexion à la Base de donnée
mongoose.connect(
process.env.DB_CONNECT,
{ useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true },
() => console.log('Connexion à la base de données effectuée'),
);
// Lancement de l'application sur le port 3000
app.listen(PORT, () => {
console.log(`Serveur démarrer : http://localhost:${PORT}`);
});