|
|
@@ -1,6 +1,6 @@
|
|
|
import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
|
import { z } from 'zod';
|
|
|
-import { AppDataSource } from '@d8d/shared-utils';
|
|
|
+import { AppDataSource, parseWithAwait } from '@d8d/shared-utils';
|
|
|
import { authMiddleware } from '@d8d/auth-module-mt';
|
|
|
import { AuthContext } from '@d8d/shared-types';
|
|
|
import { DelaySchedulerService } from '../../services/delay-scheduler.service';
|
|
|
@@ -56,15 +56,22 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
|
|
|
const status = delaySchedulerService.getStatus();
|
|
|
|
|
|
- return c.json({
|
|
|
- success: true,
|
|
|
+ // 验证响应格式
|
|
|
+ const response = {
|
|
|
+ success: true as const,
|
|
|
data: {
|
|
|
isRunning: status.isRunning,
|
|
|
- defaultDelaySeconds: status.defaultDelaySeconds,
|
|
|
- tenantId: status.tenantId,
|
|
|
- lastProcessTime: status.lastProcessTime ? status.lastProcessTime.toISOString() : null
|
|
|
+ lastRunTime: status.lastProcessTime ? status.lastProcessTime.toISOString() : null,
|
|
|
+ nextRunTime: null, // 需要从服务获取
|
|
|
+ processedTasks: 0, // 需要从服务获取
|
|
|
+ failedTasks: 0, // 需要从服务获取
|
|
|
+ pendingTasks: 0, // 需要从服务获取
|
|
|
+ tenantId: status.tenantId
|
|
|
}
|
|
|
- }, 200);
|
|
|
+ };
|
|
|
+ const validatedResponse = await parseWithAwait(SchedulerStatusResponseSchema, response);
|
|
|
+
|
|
|
+ return c.json(validatedResponse, 200);
|
|
|
});
|
|
|
|
|
|
export default app;
|