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:
18
src/lib/server/db/client.ts
Normal file
18
src/lib/server/db/client.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user