12 lines
431 B
TypeScript
12 lines
431 B
TypeScript
|
|
import type { RequestHandler } from './$types';
|
||
|
|
import { json, error } from '@sveltejs/kit';
|
||
|
|
import { getDb } from '$lib/server/db';
|
||
|
|
import { removeDomain } from '$lib/server/domains/repository';
|
||
|
|
|
||
|
|
export const DELETE: RequestHandler = async ({ params }) => {
|
||
|
|
const id = Number(params.id);
|
||
|
|
if (!Number.isInteger(id) || id <= 0) error(400, { message: 'Invalid id' });
|
||
|
|
removeDomain(getDb(), id);
|
||
|
|
return json({ ok: true });
|
||
|
|
};
|