forked from elizabethriver/LIM013-fe-burger-queen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (25 loc) · 764 Bytes
/
index.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
const express = require('express');
const config = require('./config');
const authMiddleware = require('./middleware/auth');
const errorHandler = require('./middleware/error');
const routes = require('./routes');
const pkg = require('./package.json');
const { port, dbUrl, secret } = config;
const app = express();
// TODO: Conexión a la Base de Datos (MongoDB o MySQL)
app.set('config', config);
app.set('pkg', pkg);
// parse application/x-www-form-urlencoded
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use(authMiddleware(secret));
// Registrar rutas
routes(app, (err) => {
if (err) {
throw err;
}
app.use(errorHandler);
app.listen(port, () => {
console.info(`App listening on port ${port}`);
});
});