-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (27 loc) · 853 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
37
38
39
require("dotenv").config()
const express = require('express');
const morgan = require('morgan');
const cors = require('cors');
const router = require('./routes');
const path = require('path');
require('dotenv').config()
const bodyParser = require('body-parser');
const app = express();
app.use(morgan('dev'));
app.use(cors());
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, 'public')))
app.use('/api', router);
app.get('/', (req, res) => {
res.send('Conectado')
})
app.set('port', process.env.PORT || 3000);
if (process.env.NODE_ENV !== 'test') {
app.listen(app.get('port'), () => {
console.log('Server on port ' + app.get('port') + ' on dev');
});
}
module.exports = app;