Created
October 30, 2013 06:00
-
-
Save othiym23/7227790 to your computer and use it in GitHub Desktop.
Attempt at a repro case for newrelic/node-newrelic#73 (needs more detail).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var express = require('express'); | |
var newrelic = require('newrelic'); | |
function allowCrossDomain(req, res, next) { | |
res.setHeader('Access-Control-Allow-Origin', '*'); | |
next(); | |
} | |
function time_logger(req, res, next) { | |
var stamp = new Date(); | |
console.log("DING DONG:", stamp); | |
res.set('X-Date', stamp); | |
next(); | |
} | |
function signer(req, res, next) { | |
res.set('X-Authed-By', 'othiym23'); | |
next(); | |
} | |
function authentication(req, res, next) { | |
next(); | |
} | |
var errors = { | |
middleware : function (err, req, res, next) { | |
console.log('lol:', err.message); | |
next(err); | |
} | |
}; | |
var controllers = { | |
user : { | |
show : function (req, res) { | |
res.send(200, {status : 'ok'}); | |
} | |
} | |
}; | |
var app = express(); | |
app.use(allowCrossDomain); | |
var user_show_middlewares = [ | |
time_logger, | |
express.bodyParser(), | |
signer, | |
authentication, | |
function (req, res, next) { | |
newrelic.setControllerName('users', 'show'); | |
next(); | |
}, | |
controllers.user.show | |
]; | |
app.get('/v1/users/:id', user_show_middlewares); | |
app.use(errors.middleware); | |
require('http').createServer(app).listen(8080, function () { | |
console.log("listening on port 8080"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment