-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (27 loc) · 967 Bytes
/
index.js
File metadata and controls
31 lines (27 loc) · 967 Bytes
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
require('dotenv').config();
const express = require('express');
const app = express();
const db = require('./database');
const cors = require('cors');
const bodyParser = require('body-parser');
const db_uri = process.env.DB_URI;
const handlebars = require('express-handlebars');
// ESTO ES INSEGURO POR XSS
const Handlebars = require('handlebars');
const {allowInsecurePrototypeAccess} = require('@handlebars/allow-prototype-access')
////////////////////////
const routes = require('./network/routes');
const PORT = process.env.PORT;
db(db_uri);
app.set('view engine', 'hbs');
app.engine('hbs', handlebars({
handlebars: allowInsecurePrototypeAccess(Handlebars),
layoutsDir: `${__dirname}/views/layouts`,
extname: 'hbs',
}));
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(express.static('public'));
routes(app);
app.listen(PORT, () => console.log(`app listening on http://localhost:${PORT}`));