data api with io

This commit is contained in:
tmshv committed 2016-03-23 19:38:59 +03:00
1 parent 0ffa403b60
commit aea2b8ff25
18 files changed
+162 -94

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import {put} from 'koa-route';
import compose from 'koa-compose';
import {ensureServiceAuth} from '../middlewares/ensureServiceAuth';
import data from '../data';
export function add() {
return put('/api/v1/feed', compose([
ensureServiceAuth(),
async(ctx) => {
let post = ctx.request.body;
try {
ctx.body = await data.feed.add(post);
} catch (e) {
ctx.status = 400;
ctx.body = e;
}
}
]));
}
+8
View File
@@ -0,0 +1,8 @@
import {add as feedAdd} from './feed';
import compose from 'koa-compose';
export default function () {
return compose([
feedAdd()
]);
};