This repository has been archived by the owner on Jun 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node-app.js
48 lines (40 loc) · 1.43 KB
/
node-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
'use strict';
var express = require('express');
var http = require('http');
var path = require('path');
var morgan = require('morgan'); // formerly express.logger
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var errorhandler = require('errorhandler');
var compression = require('compression');
var favicon = require('serve-favicon');
var proxyMiddleware = require('proxy-middleware');
var app = express();
// Gzip support
app.use(compression({
threshold: 512
}));
// all environments
app.set('port', process.env.PORT || 80);
app.set('views', path.join(__dirname, 'public'));
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(methodOverride());
app.use(express.static(path.join(__dirname, 'public')));
// expose bower_components (vendor files) on the /bower_components route
app.use('/bower_components', express.static(__dirname + '/bower_components'));
// development only
if ('development' === app.get('env')) {
app.use(errorhandler());
}
// Proxy requests to the Government of Canada recall database
app.use('/v1.3', proxyMiddleware(require('url').parse('http://data.tc.gc.ca/v1.3')));
app.get('/', function (req, res) {
res.render('index.html');
});
var port = app.get('port');
http.createServer(app).listen(port, function () {
console.log('Server listening on port ' + port);
});