summaryrefslogtreecommitdiff
path: root/src/server/api/api-handler.ts
diff options
context:
space:
mode:
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);
};