From 0cacc5706af8503602c3e5b2e4afb0c6db75a400 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Fri, 25 Apr 2014 00:15:33 -0700 Subject: [PATCH] use koa-is-json --- History.md | 3 ++- lib/application.js | 13 +------------ package.json | 1 + 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/History.md b/History.md index e341680..678317d 100644 --- a/History.md +++ b/History.md @@ -3,7 +3,8 @@ HEAD / ================== * refactor mime with mime-extended - + * refactor to use koa-is-json + 0.5.5 / 2014-04-14 ================== diff --git a/lib/application.js b/lib/application.js index 2631c51..19cc7bf 100644 --- a/lib/application.js +++ b/lib/application.js @@ -10,6 +10,7 @@ var compose = require('koa-compose'); var context = require('./context'); var request = require('./request'); var response = require('./response'); +var isJSON = require('koa-is-json'); var Cookies = require('cookies'); var accepts = require('accepts'); var status = require('statuses'); @@ -207,15 +208,3 @@ function *respond(next) { this.length = Buffer.byteLength(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; -} diff --git a/package.json b/package.json index efa2940..c00394a 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "mime-extended": "^1.0.0", "fresh": "~0.2.1", "koa-compose": "~2.2.0", + "koa-is-json": "~1.0.0", "cookies": "~0.4.0", "delegates": "0.0.3", "dethroy": "~1.0.0",