-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (23 loc) · 787 Bytes
/
app.js
File metadata and controls
31 lines (23 loc) · 787 Bytes
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
module.exports = function(DBClient) {
var http = require('http');
var express = require('express');
var bodyParser = require('body-parser');
var routes = require('./routes')(DBClient);
var app = express();
app.use(routes.logRequest);
app.use(bodyParser.json());
app.post('/stock', routes.insertStock);
app.get('/stock/:isbn', routes.findStock);
app.get('/', function (req, res) {
res.sendFile(__dirname + '/views/index.html');
});
app.use(routes.clientError);
app.use(routes.serverError);
var port = process.env.APP_PORT || 3000;
var server = app.listen(port, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
return app;
}