summaryrefslogtreecommitdiff
path: root/src/server/api/api-handler.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-13 09:44:00 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-13 09:44:00 +0900
commit22d2f2051c4cbe3da5b9ece674f36a6555f8c953 (patch)
tree0c29ea7c8f1797f9a28cab2d70d31e91cd9cb312 /src/server/api/api-handler.ts
parentwip (diff)
downloadsharkey-22d2f2051c4cbe3da5b9ece674f36a6555f8c953.tar.gz
sharkey-22d2f2051c4cbe3da5b9ece674f36a6555f8c953.tar.bz2
sharkey-22d2f2051c4cbe3da5b9ece674f36a6555f8c953.zip
wip
Diffstat (limited to 'src/server/api/api-handler.ts')
-rw-r--r--src/server/api/api-handler.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/server/api/api-handler.ts b/src/server/api/api-handler.ts
index 2c50234317..947794a20e 100644
--- a/src/server/api/api-handler.ts
+++ b/src/server/api/api-handler.ts
@@ -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);
};