forked from redpandabytes/skyscanner_concerts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
46 lines (38 loc) · 1.67 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
/**
========================================================================================================
Imports
========================================================================================================
**/
var path = require('path');
var dir = require('./config/dir.js');
var server = require( path.join(dir.CONFIG, 'server.js') )(); //server config, possible: manual override input
var ext = require( path.join(dir.CONFIG, 'ext.js') ); //external modules
var roam = require( path.join(dir.CONFIG, 'roam.js') );
var bodyParser = ext.bodyParser; //Converts the HTML into a printable thing in the function
/**
========================================================================================================
App : Server & Router
========================================================================================================
**/
//Start app
var app = ext.express();
//Serve : Public Assets
app.use('/public', ext.express.static('public')); // serve public files
app.use('/vendors', ext.express.static('vendors'));
console.log('Public assets ready to be served.');
//Express.js server
var httpServer = app.listen(server.PORT, "0.0.0.0");
console.log('Server mode ' + server.MODE + ' listening port ' + server.PORT );
//Manual routing
app.get('/', function(req, res) {
require( path.join(dir.CONTROLLER, 'index.js') )(req, res);
});
app.get('/test', function(req, res) {
require( path.join(dir.CONTROLLER, 'api-songkick.js') )(req, res);
});
app.get('/artist', function(req, res) {
require( path.join(dir.CONTROLLER, 'artist.js') )(req, res);
});
app.get('/results', function(req, res) {
res.sendFile(path.join(dir.VIEW, 'results.html'));
});