feat: add type dts and apiKeyObject
This commit is contained in:
@@ -13,6 +13,7 @@ export type CodeManager = {
|
||||
status?: CodeStatus;
|
||||
errorMsg?: string;
|
||||
} & Partial<RouterCode>;
|
||||
|
||||
const codeDemoRun = `async function run(ctx) {
|
||||
ctx.body = 'test js';
|
||||
return ctx;
|
||||
|
||||
@@ -170,7 +170,19 @@ getRouterApi.run = async (ctx) => {
|
||||
validator: item.validator,
|
||||
};
|
||||
});
|
||||
ctx.body = apiList;
|
||||
const apiKeyObject = apiList.reduce((pre: any, cur: any) => {
|
||||
pre[cur.key] = {
|
||||
path: cur.path,
|
||||
key: cur.key,
|
||||
description: cur.description || '',
|
||||
validator: cur.validator || {},
|
||||
};
|
||||
return pre;
|
||||
}, {});
|
||||
ctx.body = {
|
||||
list: apiList,
|
||||
keyObject: apiKeyObject,
|
||||
};
|
||||
return ctx;
|
||||
};
|
||||
getRouterApi.validator = {
|
||||
|
||||
3
src/type.ts
Normal file
3
src/type.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { CodeManager } from './admin/dashboard/load.ts';
|
||||
|
||||
export { CodeManager };
|
||||
5
src/utils/filter.ts
Normal file
5
src/utils/filter.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// 过滤掉值为 null 的字段
|
||||
export const filterNull = (updateData: Record<string, any>) => {
|
||||
const filteredData = Object.fromEntries(Object.entries(updateData).filter(([_, v]) => v !== null));
|
||||
return filteredData;
|
||||
};
|
||||
Reference in New Issue
Block a user