/**
 * Build the public or internal Fastify app for in-process testing.
 *
 * Tests use `app.inject({ method, url, headers, payload })` to issue requests —
 * this skips the HTTP layer entirely (no port binding, no socket overhead) and
 * returns a typed response object.
 *
 * Each test file should call `buildPublic()` / `buildInternal()` in beforeAll and
 * `await app.close()` in afterAll. Re-using the same app across tests in a file
 * is fine — the DB state is what's reset between tests.
 */

export const buildPublic = async () => {
  const { buildPublicApp } = await import('../../src/app.public.js')
  const app = await buildPublicApp()
  await app.ready()
  return app
}

export const buildInternal = async () => {
  const { buildInternalApp } = await import('../../src/app.internal.js')
  const app = await buildInternalApp()
  await app.ready()
  return app
}
