-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
50 lines (36 loc) · 1.69 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
"use strict";
var express = require('express');
var app = express();
//========================================================//
// Sets port to environment port or local port //
//========================================================//
var port = process.env.PORT || '4000';
//========================================================//
// connecting the client and server //
// allows for CORS (cross origin resource sharing) //
//========================================================//
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
// for more info, see: http://enable-cors.org/server_expressjs.html
//========================================================//
// statically serves files from the client directory //
//========================================================//
// This is where our private API is located
app.use(express.static('api'));
// for more info, see: http://expressjs.com/starter/static-files.html
//========================================================//
// ROUTES //
//========================================================//
// app.get('/', function(req, res) {
// res.location('/client/index.html');
// });
//========================================================//
// Calling the server //
//========================================================//
var server = app.listen(port, function() {
var host = server.address().address;
console.log('Example app listening at', host, port);
});