+ hudozka-middlewares, + hudozka-api-v1
This commit is contained in:
1 parent
6347e4db35
commit
35cc7c0caa
17 files changed
+175
-61
No files matched your search
@@ -1,31 +0,0 @@
|
||||
import {put} from 'koa-route';
|
||||
import compose from 'koa-compose';
|
||||
import {ensureServiceAuth} from '../middlewares/ensureServiceAuth';
|
||||
import {ejson} from '../middlewares/ejson';
|
||||
import query from 'koa-query';
|
||||
import {toBoolean} from 'koa-query';
|
||||
|
||||
export function add(auth, store) {
|
||||
return put('/timeline', compose([
|
||||
ensureServiceAuth(),
|
||||
ejson(),
|
||||
query({
|
||||
save: toBoolean()
|
||||
}),
|
||||
async(ctx) => {
|
||||
let doSave = ctx.request.query.save || true;
|
||||
let post = ctx.request.body;
|
||||
|
||||
try {
|
||||
if(!doSave) store.timeline.disableSaving();
|
||||
let result = await store.timeline.add(post);
|
||||
if(!doSave) store.timeline.enableSaving();
|
||||
|
||||
ctx.body = result;
|
||||
} catch (e) {
|
||||
ctx.status = 400;
|
||||
ctx.body = e;
|
||||
}
|
||||
}
|
||||
]));
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import {add as feedAdd} from './feed';
|
||||
import compose from 'koa-compose';
|
||||
|
||||
export default function (auth, store) {
|
||||
return compose([
|
||||
feedAdd(auth, store)
|
||||
]);
|
||||
};
|
||||
Reference in new issue
Block a user