Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.14 KB

README.md

File metadata and controls

43 lines (31 loc) · 1.14 KB

Derequest

De-request could help you forward a request to a list of local files. It is a simple proxy for Connect which works on top of dispatch.

Tip: Please use it before dispatch or connect.static.

Installation

npm install derequest

Sample Usage

Use it before dispatch with connect like:

var path = require('path')
,	connect = require('connect')
,	dispatch = require('dispatch')
,	derequest = require('derequest');

var _derequestVars = {
	'/javascript/bundled_js.version.js':[
		path.join(__dirname, 'javascript', 'first.js'),
		path.join(__dirname, 'javascript', 'second.js'),
		path.join(__dirname, 'javascript', 'third.js')
	],
	'/styles/bundled_css.version.css':[
		path.join(__dirname, 'styles', 'first.css'),
		path.join(__dirname, 'styles', 'second.css'),
		path.join(__dirname, 'styles', 'third.css')
	]
};

var _dispatchVars = {
	'url_pattern_1':function(req, res, next){ ... },
	'url_pattern_2':function(req, res, next){ ... }
};

connect.createServer()
	.use(derequest(_derequestVars)))
	.use(dispatch(_dispatchVars))
	.listen(8080);