forked from taljacob2/colman-advanced-web-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
25 lines (20 loc) · 708 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
const express = require('express');
const dotenv = require("dotenv");
const dotenvExpand = require("dotenv-expand");
dotenvExpand.expand(dotenv.config());
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// Error handler for invalid JSON
app.use((err, req, res, next) => {
if (err instanceof SyntaxError) {
return res.status(400).send('Invalid JSON syntax');
}
next(err);
});
const posts_routes = require('./routes/posts_routes');
app.use('/post', posts_routes);
const comments_routes = require('./routes/comments_routes');
app.use('/comment', comments_routes);
module.exports = app;