express-expose icon indicating copy to clipboard operation
express-expose copied to clipboard

Requiring after express() call

Open phzbox opened this issue 13 years ago • 2 comments

Not sure if it's considered an issue but when require('express-expose') is after var app = require('express')(), there is an error:

TypeError: Object function app(req, res){ app.handle(req, res); } has no method 'expose'

Code example that fails:

express = require('express')
app = express()
require('express-expose')
app.expose

Code example that works:

express = require("express")
require('express-expose')
app = express()
app.expose

It might strike as an odd use case but it happened while porting an app to express3.

phzbox avatar Sep 26 '12 20:09 phzbox

we should change it anyway, it should be require('express-expose')(app)

tj avatar Sep 26 '12 20:09 tj

That was the quick fix I used before understanding the ordering problem.. maybe it wasn't a total hack after all. Thanks

phzbox avatar Sep 26 '12 20:09 phzbox