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
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { buildConfig } from 'payload';
|
|
import { postgresAdapter } from '@payloadcms/db-postgres';
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
import sharp from 'sharp';
|
|
import { Users } from '@/collections/Users';
|
|
import { PAYLOAD_API_ROUTE, PAYLOAD_ADMIN_ROUTE } from '@/lib/payloadRoutes';
|
|
|
|
const filename = fileURLToPath(import.meta.url);
|
|
const dirname = path.dirname(filename);
|
|
|
|
export default buildConfig({
|
|
admin: { user: Users.slug },
|
|
// Defined in lib/payloadRoutes.ts, which carries the reasoning and is what
|
|
// the test asserts. Never inline these — /api belongs to the FastAPI proxy.
|
|
routes: { api: PAYLOAD_API_ROUTE, admin: PAYLOAD_ADMIN_ROUTE },
|
|
collections: [Users],
|
|
editor: lexicalEditor(),
|
|
secret: process.env.PAYLOAD_SECRET || '',
|
|
typescript: { outputFile: path.resolve(dirname, 'payload-types.ts') },
|
|
db: postgresAdapter({
|
|
pool: { connectionString: process.env.DATABASE_URL },
|
|
// Its own schema, so no pipeline operation on `public` can reach blog
|
|
// content. scripts/migrate_csv_to_db.py --drop lives in that blast radius,
|
|
// as does Airflow's metadata.
|
|
schemaName: 'payload',
|
|
}),
|
|
sharp,
|
|
});
|