-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
executable file
·41 lines (31 loc) · 926 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
30
31
32
33
34
35
36
37
38
39
40
41
"use strict";
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const authRoutes = require('./routes/authRoutes');
const apiRoutes = require('./routes/apiRoutes');
const agendaController = require('./controllers/agendaController');
const taskController = require('./controllers/taskController');
const app = express();
app.use(bodyParser.json());
//Create a static file server
app.use(express.static(path.join(__dirname, 'public')));
app.use('/auth', authRoutes);
app.use('/api', apiRoutes);
//create routes for agendas
agendaController(app);
//create routes for tasks
taskController(app);
app.use(function(req, res, next) {
let err = new Error('Not Found');
err.status = 404;
next(err);
});
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.json({
message: err.message,
error: err
});
});
module.exports = app;