feat: 更新获取CNB配置的路由,优化参数处理并添加错误处理

This commit is contained in:
xiongxiao
2026-03-09 19:13:20 +08:00
committed by cnb
parent a40c2352bf
commit 7d227d3913
3 changed files with 27 additions and 6 deletions

View File

@@ -21,4 +21,28 @@ app.route({
cnbManager.clearUsername(username);
}
ctx.body = { content: '已清理cnb-manager记录' };
}).addTo(app);
}).addTo(app);
app.route({
path: 'cnb',
key: 'get-my-config',
description: '获取我的cnb配置',
middleware: ['auth'],
}).define(async (ctx) => {
const username = ctx.tokenUser?.username;
const token = ctx.query?.token;
if (!username) {
ctx.throw(400, '未授权');
}
if (!token) {
ctx.throw(400, '缺少token参数');
}
const cnbItem = await cnbManager.getCNB({ username, kevisualToken: token });
if (!cnbItem) {
ctx.throw(404, '未找到cnb-manager记录');
}
ctx.body = {
token: cnbItem.token,
cookie: cnbItem.cookie,
}
}).addTo(app);