mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-12 20:06:57 +02:00
Make db a required first parameter on all service functions (notes-service, api-utils, tags, collaborators, attachments, rate-limit, sync/server). This enables unit testing with in-memory databases via createTestDb(). Also removes the NODE_ENV=test bypass from rate-limit and adds optional now parameter for time control in tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
18 lines
514 B
TypeScript
18 lines
514 B
TypeScript
import { json } from '@sveltejs/kit';
|
|
import type { RequestHandler } from './$types.js';
|
|
import { db } from '$lib/server/db/index.js';
|
|
import { getUserId } from '$lib/server/api-utils.js';
|
|
import { searchNotes } from '$lib/server/notes-service.js';
|
|
|
|
export const GET: RequestHandler = async ({ url, ...event }) => {
|
|
const userId = getUserId(event);
|
|
const query = url.searchParams.get('q')?.trim();
|
|
|
|
if (!query) {
|
|
return json([]);
|
|
}
|
|
|
|
const results = searchNotes(db, userId, query);
|
|
return json(results);
|
|
};
|