|
|
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; |
|
|
|