mirror of
https://github.com/khoaliber/dockhand.git
synced 2026-03-06 21:29:05 +00:00
Initial commit
This commit is contained in:
23
routes/api/registries/[id]/default/+server.ts
Normal file
23
routes/api/registries/[id]/default/+server.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { setDefaultRegistry, getRegistry } from '$lib/server/db';
|
||||
|
||||
export const POST: RequestHandler = async ({ params }) => {
|
||||
try {
|
||||
const id = parseInt(params.id);
|
||||
if (isNaN(id)) {
|
||||
return json({ error: 'Invalid registry ID' }, { status: 400 });
|
||||
}
|
||||
|
||||
const registry = await getRegistry(id);
|
||||
if (!registry) {
|
||||
return json({ error: 'Registry not found' }, { status: 404 });
|
||||
}
|
||||
|
||||
await setDefaultRegistry(id);
|
||||
return json({ success: true });
|
||||
} catch (error) {
|
||||
console.error('Error setting default registry:', error);
|
||||
return json({ error: 'Failed to set default registry' }, { status: 500 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user