diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-13 11:44:39 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-13 11:44:39 +0900 |
| commit | e2e7babee0de35385eb74830c82eaccdb28f013a (patch) | |
| tree | f86755ab4c60ae63e43039945a07a7ce09bc7a8e /src/server/api/api-handler.ts | |
| parent | wip (diff) | |
| download | sharkey-e2e7babee0de35385eb74830c82eaccdb28f013a.tar.gz sharkey-e2e7babee0de35385eb74830c82eaccdb28f013a.tar.bz2 sharkey-e2e7babee0de35385eb74830c82eaccdb28f013a.zip | |
wip
Diffstat (limited to 'src/server/api/api-handler.ts')
| -rw-r--r-- | src/server/api/api-handler.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/server/api/api-handler.ts b/src/server/api/api-handler.ts index 947794a20e..e716dcdc01 100644 --- a/src/server/api/api-handler.ts +++ b/src/server/api/api-handler.ts @@ -7,6 +7,8 @@ import { IUser } from '../../models/user'; import { IApp } from '../../models/app'; export default async (endpoint: Endpoint, ctx: Koa.Context) => { + const body = ctx.is('multipart/form-data') ? (ctx.req as any).body : ctx.request.body; + const reply = (x?: any, y?: any) => { if (x === undefined) { ctx.status = 204; @@ -25,7 +27,7 @@ export default async (endpoint: Endpoint, ctx: Koa.Context) => { // Authentication try { - [user, app] = await authenticate(ctx.request.body['i']); + [user, app] = await authenticate(body['i']); } catch (e) { reply(403, 'AUTHENTICATION_FAILED'); return; @@ -35,7 +37,7 @@ export default async (endpoint: Endpoint, ctx: Koa.Context) => { // API invoking try { - res = await call(endpoint, user, app, ctx.request.body, ctx.req); + res = await call(endpoint, user, app, body, (ctx.req as any).file); } catch (e) { reply(400, e); return; |