-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
38 lines (30 loc) · 1.11 KB
/
app.js
File metadata and controls
38 lines (30 loc) · 1.11 KB
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
require("dotenv").config();
const express = require("express");
const cors = require("cors");
const dbConnect = require('./config/mongo.js');
const app = express();
const path = require('path');
const morgan = require('morgan');
const hostname = '127.0.0.1';
const port = 3000;
app.use(express.static(path.join(__dirname, 'src/public')));
app.use(cors());
app.use(express.json());
app.use(express.static(path.join(__dirname, "./storage")));
app.set('src', path.join(__dirname, 'src'));
app.set('views', path.join(__dirname, 'src/views'));
app.set('css', path.join(__dirname, 'src/public/css'));
app.set('controllers', path.join(__dirname, 'controllers'));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'ejs');
app.set('port', process.env.PORT || port);
// const port = process.env.PORT || 3000;
app.use("/",require("./routes"));
app.use(express.json());
app.use(express.text());
app.use(morgan('dev'));
// app.use(express.urlencoded({extended: false}));
app.listen(app.get('port'), hostname, () => {
console.log(`Servidor escuchando en: http://${hostname} en el puerto: ` + port)
});
dbConnect();