-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (33 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
const express = require('express')
const morgan = require('morgan')
const bodyParser = require('body-parser')
const favicon = require('serve-favicon')
const sequelize = require('./src/db/sequelize')
const app = express()
const port = 3000
// MIDDLEWARES
app
.use(favicon(__dirname + '/favicon.ico'))
.use(morgan('dev'))
.use(express.json())
.use(bodyParser.json())
// Initialize Database
sequelize.initDb()
// Endpoints
require('./src/routes/findAllPokemons')(app)
require('./src/routes/findPokemonByPk.')(app)
require('./src/routes/createPokemon')(app)
require('./src/routes/updatePokemon')(app)
require('./src/routes/deletePokemon')(app)
app.listen(port, () => console.log(`\n Node App is running on : http://localhost:${port} \n`))
// Middleware Méthode 1 : Affiche dans le terminal le nom de la route et la méthode
/*const loggerTerminal = (req, res, next) => {
console.log(`${req.host} - ${req.method} : ${req.url}`)
next()
}
app.use(loggerTerminal)*/
// Middleware Méthode 2 (plus courte) : Affiche dans le terminal le nom de la route et la méthode
/*app.use((req, res, next) => {
console.log(`${req.host} - ${req.method} : ${req.url}`)
next()
})*/