24 lines
519 B
TypeScript
24 lines
519 B
TypeScript
import { app, cnb } from '../../app.ts';
|
|
|
|
app.route({
|
|
path: 'cnb',
|
|
key: 'start-workspace',
|
|
description: '启动开发工作空间, 参数 repo',
|
|
middleware: ['auth'],
|
|
metadata: {
|
|
tags: ['opencode']
|
|
}
|
|
}).define(async (ctx) => {
|
|
const repo = ctx.query?.repo;
|
|
const branch = ctx.query?.branch;
|
|
const ref = ctx.query?.ref;
|
|
if (!repo) {
|
|
ctx.throw(400, '缺少参数 repo');
|
|
}
|
|
const res = await cnb.workspace.startWorkspace(repo, {
|
|
branch,
|
|
ref
|
|
});
|
|
ctx.forward(res);
|
|
}).addTo(app);
|