File size: 936 Bytes
f6d320c ec10306 f6d320c ec10306 4594750 ec10306 4594750 f6d320c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import { Context } from 'koa';
import Router from 'koa-router';
import { handleControllerError } from '@/middleware';
import { processArticleServe, processArticleElementServe } from '@/service';
const router = new Router({ prefix: '/api' });
// 获取文章要素
router.get('/generate-article-element', async (ctx: Context) => {
try {
const result = await processArticleElementServe();
ctx.body = result;
} catch (error) {
// 将捕获到的异常传递给统一的错误处理中间件
await handleControllerError(ctx, error);
}
});
// 根据文案生成文章
router.post('/generate-article', async (ctx: Context) => {
const data = ctx.request.body as any;
try {
const result = await processArticleServe(data);
ctx.body = result;
} catch (error) {
// 将捕获到的异常传递给统一的错误处理中间件
await handleControllerError(ctx, error);
}
});
export default router;
|