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.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/server/api/api-handler.ts b/src/server/api/api-handler.ts
index 827aecdf25..2de6994f32 100644
--- a/src/server/api/api-handler.ts
+++ b/src/server/api/api-handler.ts
@@ -15,11 +15,11 @@ export default (endpoint: IEndpoint, ctx: Koa.BaseContext) => new Promise((res)
ctx.status = x;
ctx.body = {
error: {
- message: y.message,
- code: y.code,
- id: y.id,
- kind: y.kind,
- ...(y.info ? { info: y.info } : {})
+ message: y!.message,
+ code: y!.code,
+ id: y!.id,
+ kind: y!.kind,
+ ...(y!.info ? { info: y!.info } : {})
}
};
} else {
@@ -31,9 +31,9 @@ export default (endpoint: IEndpoint, ctx: Koa.BaseContext) => new Promise((res)
// Authentication
authenticate(body['i']).then(([user, app]) => {
// API invoking
- call(endpoint.name, user, app, body, (ctx.req as any).file).then(res => {
+ call(endpoint.name, user, app, body, (ctx.req as any).file).then((res: any) => {
reply(res);
- }).catch(e => {
+ }).catch((e: ApiError) => {
reply(e.httpStatusCode ? e.httpStatusCode : e.kind == 'client' ? 400 : 500, e);
});
}).catch(() => {