mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-26 14:32:04 -04:00
31 lines
805 B
TypeScript
31 lines
805 B
TypeScript
import SQL from 'sql-template-strings';
|
|
|
|
import { auditLog } from '~/server/audit.ts';
|
|
import { getLocale, loadConfig } from '~/server/data.ts';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const locale = getLocale(event);
|
|
checkIsConfigEnabledOr404(await loadConfig(locale), 'sources');
|
|
|
|
const { user, isGranted } = await useAuthentication(event);
|
|
if (!isGranted('sources')) {
|
|
throw createError({
|
|
status: 401,
|
|
statusMessage: 'Unauthorised',
|
|
});
|
|
}
|
|
|
|
const id = getRouterParam(event, 'id');
|
|
const db = useDatabase();
|
|
|
|
await db.get(SQL`
|
|
UPDATE sources
|
|
SET deleted=1
|
|
WHERE id = ${id}
|
|
`);
|
|
|
|
await invalidateCacheKind('sources', locale);
|
|
|
|
await auditLog({ user }, 'sources/removed', { id });
|
|
});
|