-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (22 loc) · 820 Bytes
/
Copy pathapp.js
File metadata and controls
29 lines (22 loc) · 820 Bytes
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 bodyParser = require('body-parser');
const cors = require('./middleware/cors');
const { unexistingRoutes, httpErrorsHandler }= require('./routes/http-errors-routes');
const usersRoures = require('./routes/users-routes');
const tasksRoures = require('./routes/tasks-routes');
module.exports = () => {
const app = express();
app.disable('x-powered-by');
// middle wares
app.use(cors);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// routes
app.use('/api/users', usersRoures);
app.use('/api/tasks', tasksRoures);
// The 404 error handler for unexisting routes
app.use(unexistingRoutes);
// The http errors handler
app.use(httpErrorsHandler);
return app;
}