良い感じに

This commit is contained in:
syuilo
2018-07-16 03:43:36 +09:00
parent 1e4a86da8e
commit 1744316656
8 changed files with 76 additions and 50 deletions

View File

@ -1,12 +1,12 @@
import * as Koa from 'koa';
import Endpoint from './endpoint';
import { IEndpoint } from './endpoints';
import authenticate from './authenticate';
import call from './call';
import { IUser } from '../../models/user';
import { IApp } from '../../models/app';
export default async (endpoint: Endpoint, ctx: Koa.Context) => {
export default async (endpoint: IEndpoint, ctx: Koa.Context) => {
const body = ctx.is('multipart/form-data') ? (ctx.req as any).body : ctx.request.body;
const reply = (x?: any, y?: any) => {
@ -37,7 +37,7 @@ export default async (endpoint: Endpoint, ctx: Koa.Context) => {
// API invoking
try {
res = await call(endpoint, user, app, body, (ctx.req as any).file);
res = await call(endpoint.name, user, app, body, (ctx.req as any).file);
} catch (e) {
reply(400, e);
return;