update packages

This commit is contained in:
2025-12-19 13:23:17 +08:00
parent 1f11013ae0
commit 76924b008c
2 changed files with 26 additions and 15 deletions

View File

@@ -17,6 +17,7 @@ export const addAuth = (app: App) => {
.route({
path: 'auth',
id: 'auth',
description: '验证token必须成功, 错误返回401正确赋值到ctx.state.tokenUser',
})
.define(async (ctx) => {
const token = ctx.query.token;
@@ -40,6 +41,7 @@ export const addAuth = (app: App) => {
path: 'auth',
key: 'can',
id: 'auth-can',
description: '验证token可以不成功错误不返回401正确赋值到ctx.state.tokenUser失败赋值null',
})
.define(async (ctx) => {
if (ctx.query?.token) {
@@ -67,6 +69,7 @@ app
id: 'auth-admin',
isDebug: true,
middleware: ['auth'],
description: '验证token必须是admin用户, 错误返回403正确赋值到ctx.state.tokenAdmin',
})
.define(async (ctx) => {
const tokenUser = ctx.state.tokenUser;
@@ -140,18 +143,26 @@ app
app
.route({
path: 'test',
key: 'test',
path: 'router',
key: 'list',
description: '列出所有的当前的可请求的路由信息',
middleware: ['auth-can']
})
.define(async (ctx) => {
ctx.body = app.router.routes.map((item) => {
return {
path: item.path,
key: item.key,
description: item.description,
validator: item.validator,
// schema: item.schema,
};
});
const tokenUser = ctx.state.tokenUser;
let isUser = !!tokenUser;
ctx.body = {
list: app.router.routes.map((item) => {
return {
id: item.id,
path: item.path,
key: item.key,
description: item.description,
middeleware: item.middleware,
metadata: item.metadata,
};
}),
isUser
}
})
.addTo(app);