mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +00:00

* chore: vitest * chore: move test files * chore: support vitest * fix: exclude test files * chore(ci): add test workflow * feat: remove read env
22 lines
482 B
TypeScript
22 lines
482 B
TypeScript
import { NextApiHandler } from '@fastgpt/service/common/middle/entry';
|
|
import { MockReqType } from '../mocks/request';
|
|
|
|
export async function Call<B = any, Q = any, R = any>(
|
|
handler: NextApiHandler<R>,
|
|
props?: MockReqType<B, Q>
|
|
) {
|
|
const { body = {}, query = {}, ...rest } = props || {};
|
|
return (await handler(
|
|
{
|
|
body: body,
|
|
query: query,
|
|
...(rest as any)
|
|
},
|
|
{} as any
|
|
)) as Promise<{
|
|
code: number;
|
|
data: R;
|
|
error?: any;
|
|
}>;
|
|
}
|