update packages
This commit is contained in:
@@ -44,11 +44,11 @@
|
|||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kevisual/ai": "^0.0.19",
|
"@kevisual/ai": "^0.0.19",
|
||||||
"@kevisual/query": "^0.0.32",
|
"@kevisual/query": "^0.0.33",
|
||||||
"@types/busboy": "^1.5.4",
|
"@types/busboy": "^1.5.4",
|
||||||
"@types/send": "^1.2.1",
|
"@types/send": "^1.2.1",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"bullmq": "^5.66.0",
|
"bullmq": "^5.66.1",
|
||||||
"busboy": "^1.6.0",
|
"busboy": "^1.6.0",
|
||||||
"commander": "^14.0.2",
|
"commander": "^14.0.2",
|
||||||
"cookie": "^1.1.1",
|
"cookie": "^1.1.1",
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
"@kevisual/logger": "^0.0.4",
|
"@kevisual/logger": "^0.0.4",
|
||||||
"@kevisual/oss": "0.0.13",
|
"@kevisual/oss": "0.0.13",
|
||||||
"@kevisual/permission": "^0.0.3",
|
"@kevisual/permission": "^0.0.3",
|
||||||
"@kevisual/router": "0.0.37",
|
"@kevisual/router": "0.0.40",
|
||||||
"@kevisual/types": "^0.0.10",
|
"@kevisual/types": "^0.0.10",
|
||||||
"@kevisual/use-config": "^1.0.21",
|
"@kevisual/use-config": "^1.0.21",
|
||||||
"@types/archiver": "^7.0.0",
|
"@types/archiver": "^7.0.0",
|
||||||
@@ -113,5 +113,5 @@
|
|||||||
"msgpackr-extract"
|
"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({
|
.route({
|
||||||
path: 'auth',
|
path: 'auth',
|
||||||
id: 'auth',
|
id: 'auth',
|
||||||
|
description: '验证token,必须成功, 错误返回401,正确赋值到ctx.state.tokenUser',
|
||||||
})
|
})
|
||||||
.define(async (ctx) => {
|
.define(async (ctx) => {
|
||||||
const token = ctx.query.token;
|
const token = ctx.query.token;
|
||||||
@@ -40,6 +41,7 @@ export const addAuth = (app: App) => {
|
|||||||
path: 'auth',
|
path: 'auth',
|
||||||
key: 'can',
|
key: 'can',
|
||||||
id: 'auth-can',
|
id: 'auth-can',
|
||||||
|
description: '验证token,可以不成功,错误不返回401,正确赋值到ctx.state.tokenUser,失败赋值null',
|
||||||
})
|
})
|
||||||
.define(async (ctx) => {
|
.define(async (ctx) => {
|
||||||
if (ctx.query?.token) {
|
if (ctx.query?.token) {
|
||||||
@@ -67,6 +69,7 @@ app
|
|||||||
id: 'auth-admin',
|
id: 'auth-admin',
|
||||||
isDebug: true,
|
isDebug: true,
|
||||||
middleware: ['auth'],
|
middleware: ['auth'],
|
||||||
|
description: '验证token,必须是admin用户, 错误返回403,正确赋值到ctx.state.tokenAdmin',
|
||||||
})
|
})
|
||||||
.define(async (ctx) => {
|
.define(async (ctx) => {
|
||||||
const tokenUser = ctx.state.tokenUser;
|
const tokenUser = ctx.state.tokenUser;
|
||||||
@@ -140,18 +143,26 @@ app
|
|||||||
|
|
||||||
app
|
app
|
||||||
.route({
|
.route({
|
||||||
path: 'test',
|
path: 'router',
|
||||||
key: 'test',
|
key: 'list',
|
||||||
|
description: '列出所有的当前的可请求的路由信息',
|
||||||
|
middleware: ['auth-can']
|
||||||
})
|
})
|
||||||
.define(async (ctx) => {
|
.define(async (ctx) => {
|
||||||
ctx.body = app.router.routes.map((item) => {
|
const tokenUser = ctx.state.tokenUser;
|
||||||
return {
|
let isUser = !!tokenUser;
|
||||||
path: item.path,
|
ctx.body = {
|
||||||
key: item.key,
|
list: app.router.routes.map((item) => {
|
||||||
description: item.description,
|
return {
|
||||||
validator: item.validator,
|
id: item.id,
|
||||||
// schema: item.schema,
|
path: item.path,
|
||||||
};
|
key: item.key,
|
||||||
});
|
description: item.description,
|
||||||
|
middeleware: item.middleware,
|
||||||
|
metadata: item.metadata,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
isUser
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.addTo(app);
|
.addTo(app);
|
||||||
|
|||||||
Reference in New Issue
Block a user