feat(TRUEREF-0002): implement repository management service and REST API

Add RepositoryService with full CRUD, ID resolution helpers, input
validation, six SvelteKit API routes (GET/POST /api/v1/libs,
GET/PATCH/DELETE /api/v1/libs/:id, POST /api/v1/libs/:id/index), and
37 unit tests covering all service operations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Giancarmine Salucci
2026-03-22 17:43:06 +01:00
parent f57b622505
commit 3d1bef5003
8 changed files with 1146 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
/**
* Provides a raw better-sqlite3 Database instance for use in services that
* need direct SQL access (not via Drizzle ORM).
*/
import Database from 'better-sqlite3';
import { env } from '$env/dynamic/private';
let _client: Database.Database | null = null;
export function getClient(): Database.Database {
if (!_client) {
if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
_client = new Database(env.DATABASE_URL);
_client.pragma('journal_mode = WAL');
_client.pragma('foreign_keys = ON');
}
return _client;
}