mirror of
https://github.com/khoaliber/dockhand.git
synced 2026-03-03 21:19:06 +00:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
/**
|
|
* Schedule Execution Detail API
|
|
*
|
|
* GET /api/schedules/executions/[id] - Returns execution details including logs
|
|
* DELETE /api/schedules/executions/[id] - Delete a schedule execution
|
|
*/
|
|
|
|
import { json } from '@sveltejs/kit';
|
|
import type { RequestHandler } from './$types';
|
|
import { getScheduleExecution, deleteScheduleExecution } from '$lib/server/db';
|
|
|
|
export const GET: RequestHandler = async ({ params }) => {
|
|
try {
|
|
const id = parseInt(params.id, 10);
|
|
if (isNaN(id)) {
|
|
return json({ error: 'Invalid execution ID' }, { status: 400 });
|
|
}
|
|
|
|
const execution = await getScheduleExecution(id);
|
|
if (!execution) {
|
|
return json({ error: 'Execution not found' }, { status: 404 });
|
|
}
|
|
|
|
return json(execution);
|
|
} catch (error: any) {
|
|
console.error('Failed to get schedule execution:', error);
|
|
return json({ error: error.message }, { status: 500 });
|
|
}
|
|
};
|
|
|
|
export const DELETE: RequestHandler = async ({ params }) => {
|
|
try {
|
|
const id = parseInt(params.id, 10);
|
|
if (isNaN(id)) {
|
|
return json({ error: 'Invalid execution ID' }, { status: 400 });
|
|
}
|
|
|
|
await deleteScheduleExecution(id);
|
|
|
|
return json({ success: true });
|
|
} catch (error: any) {
|
|
console.error('Failed to delete schedule execution:', error);
|
|
return json({ error: error.message }, { status: 500 });
|
|
}
|
|
};
|