feat: system config type;fix: retraining permission (#4772)

* feat: system config type

* fix: retraining permission
This commit is contained in:
Archer
2025-05-08 22:09:55 +08:00
committed by GitHub
parent 12d6948ba7
commit 657fa32217
9 changed files with 52 additions and 38 deletions

View File

@@ -1,5 +1,5 @@
import { jsonRes } from '../response';
import type { NextApiResponse } from 'next';
import type { NextApiRequest, NextApiResponse } from 'next';
import { withNextCors } from './cors';
import { type ApiRequestProps } from '../../type/next';
import { addLog } from '../system/log';
@@ -9,14 +9,21 @@ export type NextApiHandler<T = any> = (
res: NextApiResponse<T>
) => unknown | Promise<unknown>;
export const NextEntry = ({ beforeCallback = [] }: { beforeCallback?: Promise<any>[] }) => {
export const NextEntry = ({
beforeCallback = []
}: {
beforeCallback?: ((req: NextApiRequest, res: NextApiResponse) => Promise<any>)[];
}) => {
return (...args: NextApiHandler[]): NextApiHandler => {
return async function api(req: ApiRequestProps, res: NextApiResponse) {
const start = Date.now();
addLog.debug(`Request start ${req.url}`);
try {
await Promise.all([withNextCors(req, res), ...beforeCallback]);
await Promise.all([
withNextCors(req, res),
...beforeCallback.map((item) => item(req, res))
]);
let response = null;
for await (const handler of args) {