feat: 将所有路由的中间件从 'auth' 更新为 'admin-auth',并更新版本至 0.0.13

This commit is contained in:
2026-01-31 00:30:37 +08:00
parent 0d17d56628
commit 6e5a642ab2
13 changed files with 109 additions and 73 deletions

View File

@@ -2,31 +2,33 @@ import { createSkill } from '@kevisual/router'
import { app } from '../../app.ts'
import { tool } from '@opencode-ai/plugin/tool'
// "调用 path: cnb key: list-repos"
app.route({
path: 'call',
key: '',
description: '调用',
middleware: ['auth'],
metadata: {
tags: ['opencode'],
...createSkill({
skill: 'call-app',
title: '调用app应用',
summary: '调用router的应用, 参数path, key, payload',
args: {
path: tool.schema.string().describe('应用路径,例如 cnb'),
key: tool.schema.string().optional().describe('应用key,例如 list-repos'),
payload: tool.schema.object({}).optional().describe('调用参数'),
}
})
},
}).define(async (ctx) => {
const { path, key } = ctx.query;
console.log('call app', ctx.query);
if (!path) {
ctx.throw('路径path不能为空');
}
const res = await ctx.run({ path, key, payload: ctx.query.payload || {} });
ctx.forward(res);
}).addTo(app)
if (!app.hasRoute('call')) {
// "调用 path: cnb key: list-repos"
app.route({
path: 'call',
key: '',
description: '调用',
middleware: ['admin-auth'],
metadata: {
tags: ['opencode'],
...createSkill({
skill: 'call-app',
title: '调用app应用',
summary: '调用router的应用, 参数path, key, payload',
args: {
path: tool.schema.string().describe('应用路径,例如 cnb'),
key: tool.schema.string().optional().describe('应用key例如 list-repos'),
payload: tool.schema.object({}).optional().describe('调用参数'),
}
})
},
}).define(async (ctx) => {
const { path, key } = ctx.query;
console.log('call app', ctx.query);
if (!path) {
ctx.throw('路径path不能为空');
}
const res = await ctx.run({ path, key, payload: ctx.query.payload || {} });
ctx.forward(res);
}).addTo(app)
}