Skip to content

Commit

Permalink
Add /ping does nothing yet
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Jun 17, 2015
1 parent 35f0666 commit a47721b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app.js
Expand Up @@ -12,6 +12,7 @@ var top = require('./routes/top');
var trending = require('./routes/trending');
var badges = require('./routes/badges');
var index = require('./routes/index');
var ping = require('./routes/ping');

var app = express();

Expand All @@ -37,6 +38,7 @@ app.use('/downloads', downloads);
app.use('/top', top);
app.use('/trending', trending);
app.use('/badges', badges);
app.use('/ping', ping);
app.use('/', index);

// catch 404 and forward to error handler
Expand All @@ -53,21 +55,15 @@ app.use(function(req, res, next) {
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
next(err);
});
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
next(err);
});


Expand Down
13 changes: 13 additions & 0 deletions routes/ping.js
@@ -0,0 +1,13 @@
var express = require('express');
var router = express.Router();

router.get("/", function(req, res) {

console.log("PING");
res.set('Content-Type', 'application/json')
.set(200)
.end('{ "operation": "ping",' +
' "message": "Thanks! Live long and prosper!" }');
});

module.exports = router;

0 comments on commit a47721b

Please sign in to comment.