-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
39 lines (27 loc) · 793 Bytes
/
main.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
var http = require('http');
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
// import api route
var api = require('./api/Api');
// create servers
var httpServer = http.createServer(app);
// for parsing application/json
app.use(bodyParser.json());
// for parsing application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
if(process.env.NODE_ENV=="DEBUG" || process.env.NODE_ENV=="DEV"){
var cors = require('cors');
app.use(cors());
}
// api route
app.use('/api/',api);
//opening page
app.use('/', function (req, res) {
res.send("Server is up!");
});
var port = process.env.PORT || 3000;
// start servers
httpServer.listen(port,function(){
console.log('HTTP SERVER listening on port ' + port);
});