forked from RedHatTraining/DO288-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (28 loc) · 857 Bytes
/
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
var restify = require('restify');
var controller = require('./controllers/items');
var db = require('./models/db');
var model = require('./models/items');
model.connect(db.params, function(err) {
if (err) throw err;
});
var server = restify.createServer()
.use(restify.fullResponse())
.use(restify.queryParser())
.use(restify.bodyParser());
controller.context(server, '/todo/api', model);
server.get(/\/todo\/?.*/, restify.serveStatic({
'directory': __dirname,
'default': 'index.html'
}));
var port = process.env.PORT || 8080;
server.listen(port, function (err) {
if (err)
console.error(err);
else
console.log('App is ready at : ' + port);
});
/*
process.on('uncaughtException', function (err) {
console.error(JSON.parse(JSON.stringify(err, ['stack', 'message', 'inner'], 2)))
});
*/