File size: 610 Bytes
f6d320c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import { Context } from 'koa';
import Router from 'koa-router';
import { handleControllerError } from '@/middleware';
import { processImageServe } from '@/service';
const router = new Router({ prefix: '/api' });
// 处理接收二进制数据并转换为JPG图像的接口
router.post('/image-serve', async (ctx: Context) => {
const data = ctx.request.body;
try {
const result = await processImageServe(data);
ctx.body = result;
} catch (error) {
// 将捕获到的异常传递给统一的错误处理中间件
await handleControllerError(ctx, error);
}
});
export default router;
|