-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (31 loc) · 892 Bytes
/
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
const express = require('express');
const cookieParser = require('cookie-parser');
const cors = require("cors");
const morgan = require('morgan');
const bodyParser = require('body-parser');
const app = express();
app.use(cookieParser());
//let origin = 'https://unruffled-keller-faf15c.netlify.app/';
// if it's not in production
if (process.env.NODE_ENV === 'development') {
console.log("I am executed!");
//origin = 'http://localhost:8081';
} else {
console.log(process.env.NODE_ENV);
}
const corsOptions = {
//origin: origin,
optionsSuccessStatus: 200,
}
app.use(cors(corsOptions));
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// Main routing
require('./routes')(app);
// Running app
const port = process.env.PORT || 8082;
app.listen(port, () => {
console.log("App is running.");
});
module.exports = {app}