This commit is contained in:
syuilo
2018-04-13 09:44:00 +09:00
parent 61f21594a9
commit 22d2f2051c
10 changed files with 40 additions and 26 deletions

View File

@ -25,11 +25,21 @@ export default async (endpoint: Endpoint, ctx: Koa.Context) => {
// Authentication
try {
[user, app] = await authenticate(ctx.body['i']);
[user, app] = await authenticate(ctx.request.body['i']);
} catch (e) {
return reply(403, 'AUTHENTICATION_FAILED');
reply(403, 'AUTHENTICATION_FAILED');
return;
}
let res;
// API invoking
call(endpoint, user, app, ctx.body, ctx.req).then(reply).catch(e => reply(400, e));
try {
res = await call(endpoint, user, app, ctx.request.body, ctx.req);
} catch (e) {
reply(400, e);
return;
}
reply(res);
};