-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (41 loc) · 1.12 KB
/
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
42
43
44
45
46
47
48
49
const express = require("express");
const bodyParser = require("body-parser");
const { engine } = require("express-handlebars");
const cors = require("cors");
const morgan = require("morgan");
const { crearPreferencias } = require("./util/preferencias_mp");
const { PORT } = require("./constants");
const port = PORT;
const app = express();
//Template engine
app.engine(
"handlebars",
engine({
helpers: {
ifeq: function (a, b, options) {
if (a == b) {
return options.fn(this);
}
return options.inverse(this);
},
json: function (context) {
return JSON.stringify(context, null, 2);
},
},
})
);
app.set("view engine", "handlebars");
//Middlewares
app.use(cors());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(express.static("assets"));
app.use("/assets", express.static(__dirname + "/assets"));
app.use(morgan("dev"));
//Routes
app.use(require("./routes/phone"));
app.use(require("./routes/pago"));
crearPreferencias()
.then(() => console.log("Preferencias actualizadas"))
.catch(console.log);
app.listen(port);