Compare commits

...

24 Commits
2.1.0 ... 2.2.0

Author SHA1 Message Date
Tj Holowaychuk
45faee3e5b Release 2.2.0 2011-03-30 11:40:47 -07:00
Tj Holowaychuk
74ff735e10 Updated haml submodule 2011-03-30 11:00:47 -07:00
Tj Holowaychuk
97879f2b16 Updated formidable submodule 2011-03-30 11:00:43 -07:00
Tj Holowaychuk
1a338251ad Updated connect-form submodule 2011-03-30 11:00:34 -07:00
Tj Holowaychuk
354dc768c1 Updated jade submodule 2011-03-30 11:00:25 -07:00
Tj Holowaychuk
8a0796cd94 Updated ejs submodule 2011-03-30 11:00:21 -07:00
Tj Holowaychuk
cbc3b26584 changed express(1) --help 2011-03-30 10:58:01 -07:00
Tj Holowaychuk
d628583db8 removed colors from express(1) 2011-03-30 10:56:11 -07:00
Tj Holowaychuk
058777be1e connect >= 1.1.6 2011-03-29 18:11:00 -07:00
Tj Holowaychuk
260d03a0c4 Merge branch 'feature/route-lookup' 2011-03-29 18:04:49 -07:00
Tj Holowaychuk
6dcf6f41cc Added app.VERB() -> [Function...], app.lookup.VERB(), and app.match.VERB(). Closes #606 2011-03-29 18:04:43 -07:00
Tj Holowaychuk
799f790886 Updated connect submodule 2011-03-29 17:40:14 -07:00
Tj Holowaychuk
cb3c4b0ea9 Updated connect submodule 2011-03-29 17:38:39 -07:00
Tj Holowaychuk
798d255ba6 Release 2.1.1 2011-03-29 10:40:26 -07:00
Tj Holowaychuk
28ba9e8ac5 Fixed res.partial(); next(err) when no callback is given [reported by aheckmann] 2011-03-29 09:56:58 -07:00
Tj Holowaychuk
7888cb0506 docs 2011-03-29 09:51:38 -07:00
Tj Holowaychuk
5e284a20cc Updated connect submodule 2011-03-29 09:49:45 -07:00
Tj Holowaychuk
770357e727 Updated expresso submodule 2011-03-29 09:49:18 -07:00
Aaron Heckmann
673ba22555 res.send(undefined) returns a 204
closes #600

Signed-off-by: Tj Holowaychuk <tj@vision-media.ca>
2011-03-29 08:52:36 -07:00
Aaron Heckmann
fb38d9cfb7 add test for res.send(undefined)
Signed-off-by: Tj Holowaychuk <tj@vision-media.ca>
2011-03-29 08:52:34 -07:00
Aaron Heckmann
dda89a57ec ignore .swo .swp
Signed-off-by: Tj Holowaychuk <tj@vision-media.ca>
2011-03-29 08:52:34 -07:00
Tj Holowaychuk
62df63d3a0 doc typo 2011-03-29 08:39:35 -07:00
Tj Holowaychuk
e71696cf34 expose err.view when failing to locate a view
allows for:

   err.view.path

etc
2011-03-28 14:44:12 -07:00
Tj Holowaychuk
b5d8d58670 repo 2011-03-27 14:23:43 -07:00
20 changed files with 135 additions and 23 deletions

2
.gitignore vendored
View File

@@ -6,5 +6,7 @@ lib-cov
*.dat
*.out
*.pid
*.swp
*.swo
benchmarks/graphs
testing.js

View File

@@ -1,4 +1,19 @@
2.2.0 / 2011-03-30
==================
* Added `app.lookup.VERB()`, ex `app.lookup.put('/user/:id')`. Closes #606
* Added `app.match.VERB()`, ex `app.match.put('/user/12')`. Closes #606
* Added `app.VERB(path)` as alias of `app.lookup.VERB()`.
* Dependency `connect >= 1.1.6`
2.1.1 / 2011-03-29
==================
* Added; expose `err.view` object when failing to locate a view
* Fixed `res.partial()` call `next(err)` when no callback is given [reported by aheckmann]
* Fixed; `res.send(undefined)` responds with 204 [aheckmann]
2.1.0 / 2011-03-24
==================

View File

@@ -11,7 +11,7 @@ var fs = require('fs')
* Framework version.
*/
var version = '2.1.0';
var version = '2.2.0';
/**
* Add session support.
@@ -37,14 +37,14 @@ var templateEngine = 'jade';
var usage = ''
+ '\n'
+ ' \x1b[1mUsage\x1b[0m: express [options] [PATH]\n'
+ ' Usage: express [options] [path]\n'
+ '\n'
+ ' \x1b[1mOptions\x1b[0m:\n'
+ ' -s, --sessions Add session support\n'
+ ' -t, --template ENGINE Add template ENGINE support (jade|ejs). Defaults to jade\n'
+ ' -c, --css ENGINE Add stylesheet ENGINE support (less|sass|stylus). Defaults to plain css\n'
+ ' -v, --version Output framework version\n'
+ ' -h, --help Output help information\n'
+ ' Options:\n'
+ ' -s, --sessions add session support\n'
+ ' -t, --template <engine> add template <engine> support (jade|ejs). default=jade\n'
+ ' -c, --css <engine> add stylesheet <engine> support (less|sass|stylus). default=plain css\n'
+ ' -v, --version output framework version\n'
+ ' -h, --help output help information\n'
;
/**

View File

@@ -878,7 +878,7 @@ The _maxAge_ property may be used to set _expires_ relative to _Date.now()_ in m
res.cookie('rememberme', 'yes', { maxAge: 900000 });
To parse incoming _Cookie_ headers, use the _cookieDecoder_ middleware, which provides the _req.cookies_ object:
To parse incoming _Cookie_ headers, use the _cookieParser_ middleware, which provides the _req.cookies_ object:
app.use(express.cookieParser());

View File

@@ -27,7 +27,7 @@ var exports = module.exports = connect.middleware;
* Framework version.
*/
exports.version = '2.1.0';
exports.version = '2.2.0';
/**
* Shortcut for `new Server(...)`.

View File

@@ -44,6 +44,8 @@ Server.prototype.__proto__ = connect.HTTPServer.prototype;
Server.prototype.init = function(middleware){
var self = this;
this.match = {};
this.lookup = {};
this.settings = {};
this.redirects = {};
this.isCallbacks = {};
@@ -108,6 +110,21 @@ Server.prototype.init = function(middleware){
// register error handlers on "listening"
// so that they disregard definition position.
this.on('listening', this.registerErrorHandlers.bind(this));
// route lookup methods
methods.forEach(function(method){
self.match[method] = function(url){
return self.router.match(url, 'all' == method
? null
: method);
};
self.lookup[method] = function(path){
return self.router.lookup(path, 'all' == method
? null
: method);
};
});
};
/**
@@ -442,6 +459,13 @@ function generateMethod(method){
Server.prototype[method] = function(path, fn){
var self = this;
// Lookup
if (1 == arguments.length) {
return this.router.lookup(path, 'all' == method
? null
: method);
}
// Ensure router is mounted
if (!this.__usedRouter) {
this.use(this.router);

View File

@@ -51,7 +51,7 @@ res.send = function(body, headers, status){
status = status || this.statusCode;
// allow 0 args as 204
if (!arguments.length) body = status = 204;
if (!arguments.length || undefined === body) body = status = 204;
// determine content type
switch (typeof body) {

View File

@@ -179,8 +179,9 @@ res.partial = function(view, options, fn){
if (fn) {
fn(err);
} else {
throw err;
this.req.next(err);
}
return;
}
// callback or transfer
@@ -220,7 +221,8 @@ res.render = function(view, opts, fn, parent, sub){
// callback given
if (fn) {
fn(err);
// unwind to root call
// unwind to root call to prevent
// several next(err) calls
} else if (sub) {
throw err;
// root template, next(err)
@@ -304,7 +306,9 @@ res._render = function(view, opts, fn, parent, sub){
// Does not exist
if (!view.exists) {
if (app.enabled('hints')) hintAtViewPaths(orig, options);
throw new Error('failed to locate view "' + orig.view + '"');
var err = new Error('failed to locate view "' + orig.view + '"');
err.view = orig;
throw err;
}
// Dynamic helper support

View File

@@ -1,7 +1,7 @@
{
"name": "express",
"description": "Sinatra inspired web development framework",
"version": "2.1.0",
"version": "2.2.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"contributors": [
{ "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" },
@@ -10,11 +10,12 @@
{ "name": "Guillermo Rauch", "email": "rauchg@gmail.com" }
],
"dependencies": {
"connect": ">= 1.1.1 < 2.0.0",
"connect": ">= 1.1.6 < 2.0.0",
"mime": ">= 0.0.1",
"qs": ">= 0.0.6"
},
"keywords": ["framework", "sinatra", "web", "rest", "restful"],
"repository": "git://github.com/visionmedia/express",
"main": "index",
"bin": { "express": "./bin/express" },
"engines": { "node": ">= 0.4.1 < 0.5.0" }

View File

@@ -561,5 +561,47 @@ module.exports = {
assert.response(app,
{ url: '/user/12', method: 'OPTIONS' },
{ headers: { Allow: 'GET,PUT' }});
},
'test app.lookup': function(){
var app = express.createServer();
app.get('/user', function(){});
app.get('/user/:id', function(){});
app.get('/user/:id/:op?', function(){});
app.put('/user/:id', function(){});
app.get('/user/:id/edit', function(){});
app.get('/user').should.have.length(1);
app.get('/user/:id').should.have.length(1);
app.get('/user/:id/:op?').should.have.length(1);
app.put('/user/:id').should.have.length(1);
app.get('/user/:id/edit').should.have.length(1);
app.get('/').should.have.be.empty;
app.all('/user/:id').should.have.length(2);
app.lookup.get('/user').should.have.length(1);
app.lookup.get('/user/:id').should.have.length(1);
app.lookup.get('/user/:id/:op?').should.have.length(1);
app.lookup.put('/user/:id').should.have.length(1);
app.lookup.get('/user/:id/edit').should.have.length(1);
app.lookup.get('/').should.have.be.empty;
app.lookup.all('/user/:id').should.have.length(2);
},
'test app.match': function(){
var app = express.createServer();
app.get('/user', function(){});
app.get('/user/:id', function(){});
app.get('/user/:id/:op?', function(){});
app.put('/user/:id', function(){});
app.get('/user/:id/edit', function(){});
app.match.get('/user').should.have.length(1);
app.match.get('/user/12').should.have.length(2);
app.match.get('/user/12/:op?').should.have.length(1);
app.match.put('/user/100').should.have.length(1);
app.match.get('/user/5/edit').should.have.length(2);
app.match.get('/').should.have.be.empty;
app.match.all('/user/123').should.have.length(3);
}
};

1
test/fixtures/error.jade vendored Normal file
View File

@@ -0,0 +1 @@
= user.name

View File

@@ -50,6 +50,10 @@ module.exports = {
res.send();
});
app.get('/undefined', function(req, res, next){
res.send(undefined);
});
app.get('/bool', function(req, res, next){
res.send(true);
});
@@ -148,6 +152,13 @@ module.exports = {
assert.equal(undefined, res.headers['content-type']);
assert.equal(undefined, res.headers['content-length']);
});
assert.response(app,
{ url: '/undefined' },
{ status: 204 }, function(res){
assert.equal(undefined, res.headers['content-type']);
assert.equal(undefined, res.headers['content-length']);
});
},
'test #contentType()': function(){

View File

@@ -619,6 +619,18 @@ module.exports = {
assert.response(app,
{ url: '/root/underscore' },
{ body: '<p>Testing</p>' });
// error in template
app.get('/error', function(req, res){
process.nextTick(function(){
res.partial('error');
});
});
assert.response(app,
{ url: '/error' },
{ status: 500 });
},
'test #partial() with several calls': function(){