Skip to content

Commit

Permalink
Add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Nov 10, 2015
1 parent b54a39c commit b507ed3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Expand Up @@ -7,7 +7,7 @@ var app = express();
var gitbookMiddleware = GitBookMiddleware();

app.get('/', function (req, res) {
res.send('Hello World!');
res.redirect('https://github.com/GitbookIO/services-slack');
});

app.post('/hook/v1/:tokens([\\/.\\w]*|)', gitbookMiddleware, function (req, res, next) {
Expand All @@ -34,6 +34,11 @@ app.post('/hook/v1/:tokens([\\/.\\w]*|)', gitbookMiddleware, function (req, res,
}, next);
});

app.use(function(err, req, res, next) {
console.error(err.stack || err);
res.status(500).send(err.message || err);
});

var server = app.listen(process.env.PORT || 6001, function () {
var host = server.address().address;
var port = server.address().port;
Expand Down

0 comments on commit b507ed3

Please sign in to comment.