0.0.3 • Published 13 years ago

express-refresh v0.0.3

Weekly downloads
4
License
-
Repository
github
Last release
13 years ago

Express middleware for refreshing/reloading routes during development. Does not rely on restarting the process like other implementations.

Usage:

Just require the file, and add the middleware before the express router middleware, example:

var express-refresh = require('express-refresh');
app.configure(function(){
	...
	app.use(express-refresh());

app.use(app.router); ... });

It'll automatically detect whether or not you're in development mode, will not 'load' otherwise.

Limitations:

1) Functions in the main express file (usually 'app.js') won't get refreshed.

Therefore any route middleware / functions will not be refreshed, example:

// this function doesn't get refreshed
var getUser = function(req,res,next){ 
	next(); };
//  but the actual routing still does
app.get('/', getUser, routes.index);
  • Only workarounds are requiring people to export their functions or...
  • making the parser be able to properly parse that and call eval() on it...
  • Or... don't write route middleware inside app.js, but put it in another file.

2) That means this also won't be refreshed... inline functions, example:

app.get('/', function(req,res,next){ next(); }, routes.index);

And again, the actual routing does get refreshed, just not the function.