mirror of
https://github.com/khoaliber/dockhand.git
synced 2026-03-06 13:21:53 +00:00
Initial commit
This commit is contained in:
45
routes/api/schedules/executions/[id]/+server.ts
Normal file
45
routes/api/schedules/executions/[id]/+server.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user