-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.js
37 lines (27 loc) · 837 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
33
34
35
36
const express = require("express")
const cors = require("cors")
const db = require("./db/models/index.js")
const categoriesController = require("./src/categories/category.controller.js")
const sitesController = require("./src/categories/sites.controller.js")
const app = express()
app.use(express.json());
app.use(cors())
// app.use(clientErrorHandler)
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
categoriesController.init(app)
sitesController.init(app)
})
function clientErrorHandler(err, req, res, next) {
console.log("Error de aplicación: " + err);
res.sendStatus(err.statusCode)
// if (req.xhr) {
// res.status(500).send({ error: 'Something failed!' });
// } else {
// next(err);
// }
}