mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
* feat: team permission refine (#4402) * chore: team permission extend * feat: manage team permission * chore: api auth * fix: i18n * feat: add initv493 * fix: test, org auth manager * test: app test for refined permission * update init sh * fix: add/remove manage permission (#4427) * fix: add/remove manage permission * fix: github action fastgpt-test * fix: mock create model * fix: team write permission * fix: ts * account permission --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
This commit is contained in:
@@ -1,21 +1,35 @@
|
||||
import { NextApiHandler } from '@fastgpt/service/common/middle/entry';
|
||||
import { MockReqType } from '../mocks/request';
|
||||
import { vi } from 'vitest';
|
||||
|
||||
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(
|
||||
let raw;
|
||||
const res: any = {
|
||||
setHeader: vi.fn(),
|
||||
write: vi.fn((data: any) => {
|
||||
raw = data;
|
||||
}),
|
||||
end: vi.fn()
|
||||
};
|
||||
const response = (await handler(
|
||||
{
|
||||
body: body,
|
||||
query: query,
|
||||
body: JSON.parse(JSON.stringify(body)),
|
||||
query: JSON.parse(JSON.stringify(query)),
|
||||
...(rest as any)
|
||||
},
|
||||
{} as any
|
||||
)) as Promise<{
|
||||
res
|
||||
)) as any;
|
||||
return {
|
||||
...response,
|
||||
raw
|
||||
} as {
|
||||
code: number;
|
||||
data: R;
|
||||
error?: any;
|
||||
}>;
|
||||
raw?: any;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user