diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-04-24 15:23:48 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-04-24 15:23:48 +0900 |
| commit | 723d3e6871a6039330e870d94d187367e9c579aa (patch) | |
| tree | 637cbe640d99d6f0fc8890fdc85497a31817596f /src/server/api/define.ts | |
| parent | Merge branch 'develop' (diff) | |
| parent | 11.3.0 (diff) | |
| download | misskey-723d3e6871a6039330e870d94d187367e9c579aa.tar.gz misskey-723d3e6871a6039330e870d94d187367e9c579aa.tar.bz2 misskey-723d3e6871a6039330e870d94d187367e9c579aa.zip | |
Merge branch 'develop'
Diffstat (limited to 'src/server/api/define.ts')
| -rw-r--r-- | src/server/api/define.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/server/api/define.ts b/src/server/api/define.ts index 990cbf2a86..1e2600add0 100644 --- a/src/server/api/define.ts +++ b/src/server/api/define.ts @@ -3,6 +3,7 @@ import { ILocalUser } from '../../models/entities/user'; import { IEndpointMeta } from './endpoints'; import { ApiError } from './error'; import { App } from '../../models/entities/app'; +import { SchemaType } from '../../misc/schema'; type Params<T extends IEndpointMeta> = { [P in keyof T['params']]: NonNullable<T['params']>[P]['transform'] extends Function @@ -12,7 +13,11 @@ type Params<T extends IEndpointMeta> = { export type Response = Record<string, any> | void; -export default function <T extends IEndpointMeta>(meta: T, cb: (params: Params<T>, user: ILocalUser, app: App, file?: any, cleanup?: Function) => Promise<Response>): (params: any, user: ILocalUser, app: App, file?: any) => Promise<any> { +type executor<T extends IEndpointMeta> = + (params: Params<T>, user: ILocalUser, app: App, file?: any, cleanup?: Function) => Promise<T['res'] extends undefined ? Response : SchemaType<NonNullable<T['res']>>>; + +export default function <T extends IEndpointMeta>(meta: T, cb: executor<T>) + : (params: any, user: ILocalUser, app: App, file?: any) => Promise<any> { return (params: any, user: ILocalUser, app: App, file?: any) => { function cleanup() { fs.unlink(file.path, () => {}); |