-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
29 lines (23 loc) · 851 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
const express = require('express');
const app = express();
// NOTE: middleware function that gets executed first
app.use((req, res, next) => {
// NOTE: Body of the request (post and put request for instance)
// http://expressjs.com/en/4x/api.html#req.body
console.log('Request body: ', req.body);
// NOTE: Query string parameter
// http://expressjs.com/en/4x/api.html#req.query
console.log('Request query parameters: ',req.query);
next(); // NOTE: Don't forget to pursue to the next middleware otherwise the server stops
});
/* NOTE: possible syntax
const index = require('./controllers/index');
index(app);
*/
require('./controllers/index')(app);
require('./controllers/users')(app);
require('./controllers/bases')(app);
const port = 3000;
if (!module.parent) {
app.listen(port, () => { console.log(`Listening on port ${port}`) });
}