import type { FastifyInstance } from 'fastify'; import type { Pool } from 'pg'; import { buildApp } from '../../src/app.ts'; import { loadConfig } from '../../src/config.ts'; import { createIngestToken } from '../../src/ingest/tokens.ts'; import { TEST_SECRET } from './sign.ts'; export function testConfig() { return loadConfig({ NODE_ENV: 'test', DATABASE_URL: process.env.TEST_DATABASE_URL, INGEST_HMAC_SECRET: TEST_SECRET, LOG_LEVEL: 'silent', }); } export async function makeApp(pool: Pool): Promise<{ app: FastifyInstance; token: string }> { const app = await buildApp({ pool, config: testConfig() }); const token = await createIngestToken(pool); return { app, token }; }