Payload 3.88 runs inside the Next app against the existing Postgres, in
its own 'payload' schema so no pipeline operation on public — the app
tables, Airflow's metadata, migrate_csv_to_db.py --drop — can reach blog
content.
Its REST API is mounted at /cms-api. /api is the FastAPI proxy's
catch-all, which would swallow every admin call and forward it to the
backend with no error. The mount points live in lib/payloadRoutes.ts so
there is one definition and a test can assert it without importing
Payload: it is ESM-only, next/jest will not transform it, and appending
transformIgnorePatterns cannot un-ignore a package. Forcing it through
transpilePackages would change how the production build bundles Payload
to serve a test, so the live proof that /api still reaches FastAPI stays
where it belongs — the e2e journeys, which call /api/schools.
The package becomes ESM ("type": "module"), which Payload's CLI requires:
richtext-lexical has top-level await and the config cannot be require()d.
Only two files needed renaming, jest.config.cjs and a build script.
The build is verified to succeed with DATABASE_URL and PAYLOAD_SECRET
both unset, which is how CI builds it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017YmbBhr8s7GusjDE12hrZM
16 lines
571 B
TypeScript
16 lines
571 B
TypeScript
import { getPayload } from 'payload';
|
|
import config from '@payload-config';
|
|
import type { Payload } from 'payload';
|
|
|
|
/**
|
|
* One Payload instance per process. getPayload() is itself memoised by
|
|
* Payload, but routing every caller through here keeps the config import in a
|
|
* single place and gives page code one name to mock in tests.
|
|
*
|
|
* Never call this at module scope: CI builds the image with no database
|
|
* reachable, so a build-time connection attempt fails the build.
|
|
*/
|
|
export function getCachedPayload(): Promise<Payload> {
|
|
return getPayload({ config });
|
|
}
|