Wire the app, worker, and cleanup entry points onto Prisma Client

Task 4 rewrote src/db.js and src/jobs/jobRepository.js to use Prisma
instead of the hand-rolled mariadb pool. This updates every remaining
call site (app.js, server.js, worker.js, cleanup.js) and the 5 test
files that still referenced getPool/closePool/pool.query, so the app
and full test suite compile and run against Prisma Client.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-31 01:32:54 +02:00
co-authored by Claude Sonnet 5
parent 3a04da3180
commit 4c9fe8f616
9 changed files with 93 additions and 93 deletions
+8 -8
View File
@@ -4,29 +4,29 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import os from 'node:os';
import { createApp } from '../../src/app.js';
import { getPool, closePool } from '../../src/db.js';
import { getPrismaClient, closePrismaClient } from '../../src/db.js';
import { loadConfig } from '../../src/config.js';
import { getJobByUuid } from '../../src/jobs/jobRepository.js';
import { ensureStorageDirs } from '../../src/storage.js';
let app;
let pool;
let prisma;
let config;
beforeAll(async () => {
config = { ...loadConfig(), storageDir: await fs.mkdtemp(path.join(os.tmpdir(), 'converter-api-')) };
await ensureStorageDirs(config);
pool = getPool(config);
app = createApp(config, pool);
prisma = getPrismaClient(config);
app = createApp(config, prisma);
});
afterAll(async () => {
await closePool();
await closePrismaClient();
await fs.rm(config.storageDir, { recursive: true, force: true });
});
beforeEach(async () => {
await pool.query('DELETE FROM conversion_jobs');
await prisma.conversionJob.deleteMany();
});
describe('GET /api/formats', () => {
@@ -60,7 +60,7 @@ describe('POST /api/jobs', () => {
expect(response.body.jobs[0].status).toBe('pending');
expect(response.body.jobs[0].file).toBe('photo.png');
const job = await getJobByUuid(pool, response.body.jobs[0].id);
const job = await getJobByUuid(prisma, response.body.jobs[0].id);
expect(job.status).toBe('pending');
expect(job.sourceFormat).toBe('png');
expect(job.targetFormat).toBe('webp');
@@ -82,7 +82,7 @@ describe('POST /api/jobs', () => {
expect(response.status).toBe(201);
expect(response.body.jobs[0].status).toBe('pending');
const job = await getJobByUuid(pool, response.body.jobs[0].id);
const job = await getJobByUuid(prisma, response.body.jobs[0].id);
expect(job.quality).toBe(45);
});