use koa-is-json

This commit is contained in:
Jonathan Ong 2014-04-25 00:15:33 -07:00
parent 94dd87741e
commit 0cacc5706a
3 changed files with 4 additions and 13 deletions

View file

@ -3,6 +3,7 @@ HEAD /
================== ==================
* refactor mime with mime-extended * refactor mime with mime-extended
* refactor to use koa-is-json
0.5.5 / 2014-04-14 0.5.5 / 2014-04-14
================== ==================

View file

@ -10,6 +10,7 @@ var compose = require('koa-compose');
var context = require('./context'); var context = require('./context');
var request = require('./request'); var request = require('./request');
var response = require('./response'); var response = require('./response');
var isJSON = require('koa-is-json');
var Cookies = require('cookies'); var Cookies = require('cookies');
var accepts = require('accepts'); var accepts = require('accepts');
var status = require('statuses'); var status = require('statuses');
@ -207,15 +208,3 @@ function *respond(next) {
this.length = Buffer.byteLength(body); this.length = Buffer.byteLength(body);
res.end(body); res.end(body);
} }
/**
* Check if `body` should be interpreted as json.
*/
function isJSON(body) {
if (!body) return false;
if ('string' == typeof body) return false;
if (body instanceof Stream) return false;
if (Buffer.isBuffer(body)) return false;
return true;
}

View file

@ -32,6 +32,7 @@
"mime-extended": "^1.0.0", "mime-extended": "^1.0.0",
"fresh": "~0.2.1", "fresh": "~0.2.1",
"koa-compose": "~2.2.0", "koa-compose": "~2.2.0",
"koa-is-json": "~1.0.0",
"cookies": "~0.4.0", "cookies": "~0.4.0",
"delegates": "0.0.3", "delegates": "0.0.3",
"dethroy": "~1.0.0", "dethroy": "~1.0.0",