diff --git a/frontend/mock-db/init.ts b/frontend/mock-db/init.ts index 66d53f1..22f98f4 100644 --- a/frontend/mock-db/init.ts +++ b/frontend/mock-db/init.ts @@ -5,13 +5,16 @@ import { statuses } from 'wildebeest/frontend/src/dummyData' import type { Account, MastodonStatus } from 'wildebeest/frontend/src/types' const kek = 'test-kek' +/* eslint-disable @typescript-eslint/no-empty-function */ const queue = { async send() {}, async sendBatch() {}, } -const kv_cache: any = { +const kv_cache = { async put() {}, } +/* eslint-enable @typescript-eslint/no-empty-function */ + /** * Run helper commands to initialize the database with actors, statuses, etc. */ @@ -46,7 +49,7 @@ async function createStatus(db: D1Database, actor: Person, status: string, visib headers, body: JSON.stringify(body), }) - const resp = await statusesAPI.handleRequest(req, db, actor, kek, queue, kv_cache) + const resp = await statusesAPI.handleRequest(req, db, actor, kek, queue, kv_cache as unknown as KVNamespace) return (await resp.json()) as MastodonStatus } diff --git a/frontend/mock-db/worker.ts b/frontend/mock-db/worker.ts index 16b06d8..d0439c1 100644 --- a/frontend/mock-db/worker.ts +++ b/frontend/mock-db/worker.ts @@ -12,9 +12,11 @@ const handler: ExportedHandler = { const domain = new URL(req.url).hostname try { await init(domain, DATABASE) + // eslint-disable-next-line no-console console.log('Database initialized.') } catch (e) { if (isD1ConstraintError(e)) { + // eslint-disable-next-line no-console console.log('Database already initialized.') } else { throw e @@ -29,7 +31,10 @@ const handler: ExportedHandler = { * which will indicate that the database was already populated. */ function isD1ConstraintError(e: unknown) { - return (e as any).message === 'D1_RUN_ERROR' && (e as any).cause?.code === 'SQLITE_CONSTRAINT_PRIMARYKEY' + return ( + (e as { message: string }).message === 'D1_RUN_ERROR' && + (e as { cause?: { code: string } }).cause?.code === 'SQLITE_CONSTRAINT_PRIMARYKEY' + ) } export default handler diff --git a/frontend/package.json b/frontend/package.json index 61213e7..fbb41c9 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,7 +7,7 @@ }, "private": true, "scripts": { - "lint": "eslint src", + "lint": "eslint src mock-db test adaptors", "build": "vite build && vite build -c adaptors/cloudflare-pages/vite.config.ts", "dev": "vite --mode ssr", "watch": "concurrently \"vite build -w\" \"vite build -w -c adaptors/cloudflare-pages/vite.config.ts\"" diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index fe10de1..cc738b3 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -22,5 +22,5 @@ "wildebeest/*": ["../*"] } }, - "include": ["src", "mock-db", "../backend/src", "../config", "../functions"] + "include": ["src", "mock-db", "test", "adaptors","../backend/src", "../config", "../functions"] }