feat: refactor route definitions and enhance metadata for app domain manager

- Updated route definitions in `src/route.ts` to utilize `toJSONSchema` and `pick` for cleaner route listing.
- Enhanced the `app.domain.manager` routes in `src/routes/app-manager/domain/manager.ts`:
  - Changed path format to snake_case.
  - Added descriptions for each route.
  - Introduced Zod schema validation for request arguments in metadata.
This commit is contained in:
2026-02-18 03:17:45 +08:00
parent 8c6d57d228
commit 6c611dcf78
4 changed files with 430 additions and 270 deletions

View File

@@ -4,6 +4,8 @@ import { app } from './app.ts';
import type { App } from '@kevisual/router';
import { User } from './models/user.ts';
import { createCookie, getSomeInfoFromReq } from './routes/user/me.ts';
import { toJSONSchema } from '@kevisual/router';
import { pick } from 'es-toolkit';
/**
* 添加auth中间件, 用于验证token
@@ -169,22 +171,17 @@ app
.define(async (ctx) => {
const tokenUser = ctx.state.tokenUser;
let isUser = !!tokenUser;
const routesList = app.router.routes.filter(item => {
if (item.id === 'auth' || item.id === 'auth-can' || item.id === 'check-auth-admin' || item.id === 'auth-admin') {
return false;
}
return true;
}).map((item) => {
const route = pick(item, ['id', 'path', 'key', 'description', 'middleware'] as const);
return toJSONSchema(route);
})
ctx.body = {
list: app.router.routes.filter(item => {
if (item.id === 'auth' || item.id === 'auth-can' || item.id === 'check-auth-admin' || item.id === 'auth-admin') {
return false;
}
return true;
}).map((item) => {
return {
id: item.id,
path: item.path,
key: item.key,
description: item.description,
middeleware: item.middleware,
metadata: item.metadata,
};
}),
list: routesList,
isUser
}
})