Comparing version 2.3.0 to 2.3.1
2.3.1 / 2011-04-26 | ||
================== | ||
* Added `app.match()` as `app.match.all()` | ||
* Added `app.lookup()` as `app.lookup.all()` | ||
* Added `app.remove()` for `app.remove.all()` | ||
* Added `app.remove.VERB()` | ||
* Fixed template caching collision issue. Closes #644 | ||
* Moved router over from connect and started refactor | ||
2.3.0 / 2011-04-25 | ||
@@ -16,3 +26,2 @@ ================== | ||
2.2.2 / 2011-04-12 | ||
@@ -19,0 +28,0 @@ ================== |
@@ -14,3 +14,4 @@ | ||
, HTTPSServer = require('./https') | ||
, HTTPServer = require('./http'); | ||
, HTTPServer = require('./http') | ||
, Route = require('./router/route') | ||
@@ -31,3 +32,3 @@ /** | ||
exports.version = '2.3.0'; | ||
exports.version = '2.3.1'; | ||
@@ -56,2 +57,3 @@ /** | ||
exports.HTTPSServer = HTTPSServer; | ||
exports.Route = Route; | ||
@@ -58,0 +60,0 @@ /** |
@@ -14,3 +14,3 @@ | ||
, connect = require('connect') | ||
, router = connect.router | ||
, router = require('./router') | ||
, methods = router.methods.concat(['del', 'all']) | ||
@@ -22,2 +22,14 @@ , view = require('./view') | ||
/** | ||
* Expose `HTTPServer`. | ||
*/ | ||
exports = module.exports = HTTPServer; | ||
/** | ||
* Server proto. | ||
*/ | ||
var app = HTTPServer.prototype; | ||
/** | ||
* Initialize a new `HTTPServer` with optional `middleware`. | ||
@@ -29,3 +41,3 @@ * | ||
var Server = exports = module.exports = function HTTPServer(middleware){ | ||
function HTTPServer(middleware){ | ||
connect.HTTPServer.call(this, []); | ||
@@ -39,3 +51,3 @@ this.init(middleware); | ||
Server.prototype.__proto__ = connect.HTTPServer.prototype; | ||
app.__proto__ = connect.HTTPServer.prototype; | ||
@@ -49,7 +61,5 @@ /** | ||
Server.prototype.init = function(middleware){ | ||
app.init = function(middleware){ | ||
var self = this; | ||
this.cache = {}; | ||
this.match = {}; | ||
this.lookup = {}; | ||
this.settings = {}; | ||
@@ -62,6 +72,3 @@ this.redirects = {}; | ||
// default "home" to / | ||
this.set('home', '/'); | ||
// set "env" to NODE_ENV, defaulting to "development" | ||
this.set('env', process.env.NODE_ENV || 'development'); | ||
@@ -116,2 +123,14 @@ | ||
// route lookup methods | ||
this.remove = function(url){ | ||
return self.remove.all(url); | ||
}; | ||
this.match = function(url){ | ||
return self.match.all(url); | ||
}; | ||
this.lookup = function(url){ | ||
return self.lookup.all(url); | ||
}; | ||
methods.forEach(function(method){ | ||
@@ -124,2 +143,8 @@ self.match[method] = function(url){ | ||
self.remove[method] = function(url){ | ||
return self.router.remove(url, 'all' == method | ||
? null | ||
: method); | ||
}; | ||
self.lookup[method] = function(path){ | ||
@@ -137,3 +162,3 @@ return self.router.lookup(path, 'all' == method | ||
Server.prototype.onvhost = function(){ | ||
app.onvhost = function(){ | ||
this.registerErrorHandlers(); | ||
@@ -149,3 +174,3 @@ }; | ||
Server.prototype.registerErrorHandlers = function(){ | ||
app.registerErrorHandlers = function(){ | ||
this.errorHandlers.forEach(function(fn){ | ||
@@ -169,3 +194,3 @@ this.use(function(err, req, res, next){ | ||
Server.prototype.use = function(route, middleware){ | ||
app.use = function(route, middleware){ | ||
var app, home, handle; | ||
@@ -228,3 +253,3 @@ | ||
Server.prototype.mounted = function(fn){ | ||
app.mounted = function(fn){ | ||
this.__mounted = fn; | ||
@@ -241,3 +266,3 @@ return this; | ||
Server.prototype.register = function(){ | ||
app.register = function(){ | ||
view.register.apply(this, arguments); | ||
@@ -256,4 +281,4 @@ return this; | ||
Server.prototype.helpers = | ||
Server.prototype.locals = function(obj){ | ||
app.helpers = | ||
app.locals = function(obj){ | ||
utils.merge(this._locals, obj); | ||
@@ -272,3 +297,3 @@ return this; | ||
Server.prototype.dynamicHelpers = function(obj){ | ||
app.dynamicHelpers = function(obj){ | ||
utils.merge(this.dynamicViewHelpers, obj); | ||
@@ -321,3 +346,3 @@ return this; | ||
Server.prototype.param = function(name, fn){ | ||
app.param = function(name, fn){ | ||
if (Array.isArray(name)) { | ||
@@ -343,3 +368,3 @@ name.forEach(function(name){ | ||
Server.prototype.error = function(fn){ | ||
app.error = function(fn){ | ||
this.errorHandlers.push(fn); | ||
@@ -358,3 +383,3 @@ return this; | ||
Server.prototype.is = function(type, fn){ | ||
app.is = function(type, fn){ | ||
if (!fn) return this.isCallbacks[type]; | ||
@@ -375,3 +400,3 @@ this.isCallbacks[type] = fn; | ||
Server.prototype.set = function(setting, val){ | ||
app.set = function(setting, val){ | ||
if (val === undefined) { | ||
@@ -397,3 +422,3 @@ if (this.settings.hasOwnProperty(setting)) { | ||
Server.prototype.enabled = function(setting){ | ||
app.enabled = function(setting){ | ||
return !!this.set(setting); | ||
@@ -410,3 +435,3 @@ }; | ||
Server.prototype.disabled = function(setting){ | ||
app.disabled = function(setting){ | ||
return !this.set(setting); | ||
@@ -423,3 +448,3 @@ }; | ||
Server.prototype.enable = function(setting){ | ||
app.enable = function(setting){ | ||
return this.set(setting, true); | ||
@@ -436,3 +461,3 @@ }; | ||
Server.prototype.disable = function(setting){ | ||
app.disable = function(setting){ | ||
return this.set(setting, false); | ||
@@ -450,3 +475,3 @@ }; | ||
Server.prototype.redirect = function(key, url){ | ||
app.redirect = function(key, url){ | ||
this.redirects[key] = url; | ||
@@ -465,3 +490,3 @@ return this; | ||
Server.prototype.configure = function(env, fn){ | ||
app.configure = function(env, fn){ | ||
if ('function' == typeof env) { | ||
@@ -479,3 +504,3 @@ fn = env, env = 'all'; | ||
function generateMethod(method){ | ||
Server.prototype[method] = function(path){ | ||
app[method] = function(path){ | ||
var self = this; | ||
@@ -504,2 +529,2 @@ | ||
Server.prototype.del = Server.prototype.delete; | ||
app.del = app.delete; |
@@ -17,2 +17,14 @@ | ||
/** | ||
* Expose `HTTPSServer`. | ||
*/ | ||
exports = module.exports = HTTPSServer; | ||
/** | ||
* Server proto. | ||
*/ | ||
var app = HTTPSServer.prototype; | ||
/** | ||
* Initialize a new `HTTPSServer` with the | ||
@@ -26,3 +38,3 @@ * given `options`, and optional `middleware`. | ||
var Server = exports = module.exports = function HTTPSServer(options, middleware){ | ||
function HTTPSServer(options, middleware){ | ||
connect.HTTPSServer.call(this, options, []); | ||
@@ -36,3 +48,3 @@ this.init(middleware); | ||
Server.prototype.__proto__ = connect.HTTPSServer.prototype; | ||
app.__proto__ = connect.HTTPSServer.prototype; | ||
@@ -42,3 +54,3 @@ // mixin HTTPServer methods | ||
Object.keys(HTTPServer.prototype).forEach(function(method){ | ||
Server.prototype[method] = HTTPServer.prototype[method]; | ||
app[method] = HTTPServer.prototype[method]; | ||
}); |
@@ -200,3 +200,3 @@ | ||
formatters.__proto__ = flashFormatters; | ||
msg = utils.miniMarkdown(utils.htmlEscape(msg)); | ||
msg = utils.miniMarkdown(utils.escape(msg)); | ||
msg = msg.replace(/%([a-zA-Z])/g, function(_, format){ | ||
@@ -203,0 +203,0 @@ var formatter = formatters[format]; |
@@ -9,60 +9,2 @@ | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var path = require('path') | ||
, basename = path.basename | ||
, dirname = path.dirname | ||
, extname = path.extname; | ||
/** | ||
* Memory cache. | ||
*/ | ||
var cache = { | ||
basename: {} | ||
, dirname: {} | ||
, extname: {} | ||
}; | ||
/** | ||
* Cached basename. | ||
* | ||
* @param {String} path | ||
* @return {String} | ||
* @api private | ||
*/ | ||
exports.basename = function(path){ | ||
return cache.basename[path] | ||
|| (cache.basename[path] = basename(path)); | ||
}; | ||
/** | ||
* Cached dirname. | ||
* | ||
* @param {String} path | ||
* @return {String} | ||
* @api private | ||
*/ | ||
exports.dirname = function(path){ | ||
return cache.dirname[path] | ||
|| (cache.dirname[path] = dirname(path)); | ||
}; | ||
/** | ||
* Cached extname. | ||
* | ||
* @param {String} path | ||
* @return {String} | ||
* @api private | ||
*/ | ||
exports.extname = function(path){ | ||
return cache.extname[path] | ||
|| (cache.extname[path] = extname(path)); | ||
}; | ||
/** | ||
* Merge object `b` with `a` giving precedence to | ||
@@ -93,2 +35,23 @@ * values in object `a`. | ||
/** | ||
* Flatten the given `arr`. | ||
* | ||
* @param {Array} arr | ||
* @return {Array} | ||
* @api private | ||
*/ | ||
exports.flatten = function(arr, ret){ | ||
var ret = ret || [] | ||
, len = arr.length; | ||
for (var i = 0; i < len; ++i) { | ||
if (Array.isArray(arr[i])) { | ||
exports.flatten(arr[i], ret); | ||
} else { | ||
ret.push(arr[i]); | ||
} | ||
} | ||
return ret; | ||
}; | ||
/** | ||
* Parse mini markdown implementation. | ||
@@ -122,3 +85,3 @@ * The following conversions are supported, | ||
exports.htmlEscape = function(html) { | ||
exports.escape = function(html) { | ||
return String(html) | ||
@@ -125,0 +88,0 @@ .replace(/&/g, '&') |
@@ -262,2 +262,5 @@ | ||
// cache id | ||
var cid = view + (parent ? ':' + parent.path : ''); | ||
// merge "view options" | ||
@@ -327,4 +330,4 @@ if (viewOptions) merge(options, viewOptions); | ||
// cached view | ||
if (app.cache[view]) { | ||
view = app.cache[view]; | ||
if (app.cache[cid]) { | ||
view = app.cache[cid]; | ||
options.filename = view.path; | ||
@@ -365,3 +368,3 @@ // resolve view | ||
view.fn = engine.compile(view.contents, options) | ||
if (cacheViews) app.cache[orig.view] = view; | ||
if (cacheViews) app.cache[cid] = view; | ||
} | ||
@@ -368,0 +371,0 @@ |
@@ -12,6 +12,6 @@ | ||
var utils = require('../utils') | ||
, extname = utils.extname | ||
, dirname = utils.dirname | ||
, basename = utils.basename | ||
var path = require('path') | ||
, extname = path.extname | ||
, dirname = path.dirname | ||
, basename = path.basename | ||
, fs = require('fs') | ||
@@ -21,2 +21,8 @@ , stat = fs.statSync; | ||
/** | ||
* Expose `View`. | ||
*/ | ||
exports = module.exports = View; | ||
/** | ||
* Require cache. | ||
@@ -35,3 +41,3 @@ */ | ||
var View = exports = module.exports = function View(view, options) { | ||
function View(view, options) { | ||
options = options || {}; | ||
@@ -38,0 +44,0 @@ this.view = view; |
{ | ||
"name": "express", | ||
"description": "Sinatra inspired web development framework", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97109
20
2201