+ hudozka-middlewares, + hudozka-api-v1

This commit is contained in:
tmshv committed 2016-03-26 21:53:20 +03:00
1 parent 6347e4db35
commit 35cc7c0caa
17 files changed
+175 -61

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
import {parse} from 'ejson';
export function ejson(type='application/ejson') {
return async (ctx, next) => {
let t = ctx.request.headers['content-type'];
let data = ctx.request.body;
if (t === type){
data = typeof data === 'string' ? data : JSON.stringify(data);
ctx.request.body = parse(data);
}
await next();
};
}