-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (29 loc) · 1.03 KB
/
server.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
const express = require('express'),
bodyParser = require('body-parser'),
path = require('path'),
app = express();
// require('dotenv').config();
// --------- CARGAR VISTAS --------- //
const productsUri = require('./presentation/products/view');
const scraperUri = require('./presentation/scraped/view');
const scraperNotificationsUri = require('./presentation/notifications/view');
const reportsUri = require('./presentation/reports/view');
const port = process.env._PORT || 8081;
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
console.log(`ruta ${__dirname}`);
/* Rutas */
app.use('/api/products', productsUri);
app.use('/api/scraper', scraperUri);
app.use('/api/notifications', scraperNotificationsUri);
app.use('/api/reports', reportsUri);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
let err = {};
err.error = "No se encontro " + req.originalUrl;
err.status = 404;
res.status(404).send(err);
//next(err);
});
app.listen(port);
console.log("Running on " + port);