16 lines
484 B
TypeScript
16 lines
484 B
TypeScript
import type { RequestHandler } from './$types';
|
|
import { getDb } from '$lib/server/db';
|
|
import { scanLibraries } from '$lib/server/scanner';
|
|
import { getSession } from '$lib/server/auth';
|
|
|
|
export const POST: RequestHandler = ({ cookies }) => {
|
|
if (!getSession(cookies)) {
|
|
return new Response('Unauthorized', { status: 401 });
|
|
}
|
|
const db = getDb();
|
|
scanLibraries(db);
|
|
return new Response(JSON.stringify({ ok: true }), {
|
|
headers: { 'Content-Type': 'application/json' }
|
|
});
|
|
};
|