update packages
This commit is contained in:
@@ -44,11 +44,11 @@
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@kevisual/ai": "^0.0.19",
|
||||
"@kevisual/query": "^0.0.32",
|
||||
"@kevisual/query": "^0.0.33",
|
||||
"@types/busboy": "^1.5.4",
|
||||
"@types/send": "^1.2.1",
|
||||
"@types/ws": "^8.18.1",
|
||||
"bullmq": "^5.66.0",
|
||||
"bullmq": "^5.66.1",
|
||||
"busboy": "^1.6.0",
|
||||
"commander": "^14.0.2",
|
||||
"cookie": "^1.1.1",
|
||||
@@ -68,7 +68,7 @@
|
||||
"@kevisual/logger": "^0.0.4",
|
||||
"@kevisual/oss": "0.0.13",
|
||||
"@kevisual/permission": "^0.0.3",
|
||||
"@kevisual/router": "0.0.37",
|
||||
"@kevisual/router": "0.0.40",
|
||||
"@kevisual/types": "^0.0.10",
|
||||
"@kevisual/use-config": "^1.0.21",
|
||||
"@types/archiver": "^7.0.0",
|
||||
@@ -113,5 +113,5 @@
|
||||
"msgpackr-extract"
|
||||
]
|
||||
},
|
||||
"packageManager": "pnpm@10.26.0"
|
||||
"packageManager": "pnpm@10.26.1"
|
||||
}
|
||||
33
src/route.ts
33
src/route.ts
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user