Comparing version 0.1.1 to 0.1.2
@@ -0,2 +1,15 @@ | ||
HEAD | ||
================== | ||
0.1.1 / 2013-21-21 | ||
================== | ||
* update co, koa-compose, keygrip | ||
* use on-socket-error | ||
* add throw(status, msg) support | ||
* assert middleware is GeneratorFunction | ||
* ducktype stream checks | ||
* remove `next` is `app.callback()` | ||
0.1.1 / 2013-12-19 | ||
@@ -3,0 +16,0 @@ ================== |
@@ -6,2 +6,3 @@ /** | ||
var debug = require('debug')('koa:application'); | ||
var onSocketError = require('on-socket-error'); | ||
var Emitter = require('events').EventEmitter; | ||
@@ -14,3 +15,3 @@ var compose = require('koa-compose'); | ||
var Keygrip = require('keygrip'); | ||
var Stream = require('stream'); | ||
var assert = require('assert'); | ||
var http = require('http'); | ||
@@ -76,3 +77,3 @@ var co = require('co'); | ||
* | ||
* @param {Function} fn | ||
* @param {GeneratorFunction} fn | ||
* @return {Application} self | ||
@@ -83,2 +84,3 @@ * @api public | ||
app.use = function(fn){ | ||
assert('GeneratorFunction' == fn.constructor.name, 'app.use() requires a generator function'); | ||
debug('use %s', fn.name || '-'); | ||
@@ -100,9 +102,9 @@ this.middleware.push(fn); | ||
var gen = compose(mw); | ||
var fn = co(gen); | ||
var self = this; | ||
return function(req, res, next){ | ||
return function(req, res){ | ||
var ctx = self.createContext(req, res); | ||
next = next || ctx.onerror; | ||
ctx.onSocketError(next); | ||
co.call(ctx, gen)(next); | ||
onSocketError(ctx, ctx.onerror); | ||
fn.call(ctx, ctx.onerror); | ||
} | ||
@@ -221,3 +223,3 @@ }; | ||
// Stream body | ||
if (body instanceof Stream) { | ||
if ('function' == typeof body.pipe) { | ||
if (!~body.listeners('error').indexOf(this.onerror)) body.on('error', this.onerror); | ||
@@ -224,0 +226,0 @@ |
@@ -47,6 +47,7 @@ | ||
* this.throw('name required', 400) | ||
* this.throw(400, 'name required') | ||
* this.throw('something exploded') | ||
* | ||
* @param {String|Number} msg | ||
* @param {Number} status | ||
* @param {String|Number} msg or status | ||
* @param {String|Number} msg or status | ||
* @api public | ||
@@ -56,6 +57,5 @@ */ | ||
throw: function(msg, status){ | ||
// TODO: switch order... feels weird now that im used to express | ||
if ('number' == typeof msg) { | ||
var tmp = msg; | ||
msg = http.STATUS_CODES[tmp]; | ||
msg = status || http.STATUS_CODES[tmp]; | ||
status = tmp; | ||
@@ -493,18 +493,2 @@ } | ||
}, | ||
/** | ||
* Invoke `fn` on socket errors and | ||
* handle cleanup on response. | ||
* | ||
* @param {Function} fn | ||
* @api private | ||
*/ | ||
onSocketError: function(fn){ | ||
var sock = this.socket; | ||
sock.once('error', fn); | ||
this.res.on('finish', function(){ | ||
sock.removeListener('error', fn); | ||
}); | ||
} | ||
}; |
@@ -8,3 +8,2 @@ | ||
var statuses = require('./status'); | ||
var Stream = require('stream'); | ||
var http = require('http'); | ||
@@ -137,3 +136,3 @@ var path = require('path'); | ||
// stream | ||
if (val instanceof Stream) { | ||
if ('function' == typeof val.pipe) { | ||
if (setType) this.type = 'bin'; | ||
@@ -140,0 +139,0 @@ return; |
{ | ||
"name": "koa", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Koa web app framework", | ||
@@ -24,3 +24,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"co": "~2.3.0", | ||
"on-socket-error": "~1.0.1", | ||
"co": "~3.0.1", | ||
"debug": "*", | ||
@@ -30,5 +31,5 @@ "mime": "~1.2.11", | ||
"negotiator": "~0.3.0", | ||
"koa-compose": "~2.0.0", | ||
"koa-compose": "~2.0.1", | ||
"cookies": "~0.3.7", | ||
"keygrip": "~0.2.4" | ||
"keygrip": "~1.0.0" | ||
}, | ||
@@ -38,3 +39,3 @@ "devDependencies": { | ||
"should": "~2.1.0", | ||
"mocha": "~1.14.0", | ||
"mocha": "~1.16.0", | ||
"supertest": "~0.8.1", | ||
@@ -44,12 +45,12 @@ "co-fs": "~1.1", | ||
"ejs": "~0.8.4", | ||
"koa-logger": "~1.0.1", | ||
"koa-static": "~1.2.0", | ||
"co-busboy": "git://github.com/cojs/busboy", | ||
"koa-logger": "~1.1.0", | ||
"koa-static": "~1.4.0", | ||
"co-busboy": "~0.1.0", | ||
"koa-route": "~1.0.2", | ||
"swig": "~1.1.0", | ||
"swig": "~1.2.0", | ||
"co-body": "0.0.1" | ||
}, | ||
"engines": { | ||
"node": "> 0.11.4" | ||
"node": ">= 0.11.9" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
![koa middleware framework for nodejs](https://dl.dropboxusercontent.com/u/6396913/koa/logo.png) | ||
![koa middleware framework for nodejs](https://dl.dropboxusercontent.com/u/6396913/koa/logo-small.jpg) | ||
@@ -6,3 +6,3 @@ [![Build Status](https://travis-ci.org/koajs/koa.png)](https://travis-ci.org/koajs/koa) | ||
Expressive middleware for node.js using generators via [co](https://github.com/visionmedia/co) | ||
to make web applications and REST APIs more enjoyable to write. | ||
to make web applications and APIs more enjoyable to write. Koa's middleware flow in a stack-like manner allowing you to perform actions downstream, then filter and manipulate the response upstream. Koa's use of generators also greatly increases the readability and robustness of your application. | ||
@@ -28,2 +28,6 @@ Only methods that are common to nearly all HTTP servers are integrated directly into Koa's small ~400 SLOC codebase. This | ||
Another option, if you would like to use koa with __node 0.10.x__ (the current | ||
stable branch), or are tired of typing the `--harmony` flag, is to use | ||
[`gnode`](https://github.com/TooTallNate/gnode) to spawn your node instance. | ||
## Community | ||
@@ -30,0 +34,0 @@ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
41769
116
9
1548
5
+ Addedon-socket-error@~1.0.1
+ Addedco@3.0.6(transitive)
+ Addedkeygrip@1.0.3(transitive)
+ Addedon-socket-error@1.0.1(transitive)
- Removedco@2.3.0(transitive)
- Removedkeygrip@0.2.4(transitive)
Updatedco@~3.0.1
Updatedkeygrip@~1.0.0
Updatedkoa-compose@~2.0.1