-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
46 lines (36 loc) · 1.02 KB
/
server.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
40
41
42
43
44
45
46
'use strict';
// constants
var PORT = 80;
var SERVER = "0.0.0.0";
var ENV = "dev"; // dev | prod
// modules
var express = require('express');
var bodyParser = require('body-parser');
var mysql = require('mysql');
// configuration
// var config = require('./app/config/api')(ENV);
// console.log(config);
// team
var app = express();
// allow access for AJAX calls from any domain
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
}
app.use(allowCrossDomain);
// the client app lives here
app.use(express.static('/root/fm-client/dist'));
// support URL-encoded bodies
app.use(bodyParser.urlencoded({
extended: true
}));
// routes
['api'].forEach(function(route){
require('./app/routes/' + route)(app);
});
// Run Forrest, run!
app.listen(PORT, SERVER, function (){
console.log("Server started on " + SERVER + ":" + PORT);
});