CodeVetter · Repo Unpack · Data flow
payloadcms/payload
Configuration is transformed before runtime state is initialized. HTTP requests acquire authentication, query, locale, and translation context before endpoint handlers consume data. Collection operations own validation and lifecycle behavior, then delegate stored representations to adapters. Returned documents are transformed again for field visibility, population, localization, and hooks before crossing the response boundary.
- buildConfig sorts plugins by order, awaits each config transformation, invokes each storage adapter's init, and finally passes the resulting config to sanitizeConfig.
- createPayloadRequestFromWebRequest parses cookies, gets a cached Payload instance with crons enabled, parses query strings with depth 10 and arrayLimit 1000, and normalizes configured locales.
- createPayloadRequest attaches Payload, context, i18n, user, and a request dataloader; the web wrapper then executes auth strategies and attaches the resulting user and response headers.
- Internal POST/PATCH endpoint wrappers parse data/files and body locales before calling the original handler; JSON becomes req.data, while multipart _payload supplies data and file parts populate req.files/req.file.
- The client Form reduces fields to values, runs optional beforeSubmit and form validation, builds FormData, then either sends an HTTP request with Accept-Language or calls a function action.
- createLocal resolves a collection, defaults overrideAccess to false, constructs request context, and resolves req.file from an explicit file or filePath before entering the shared create path.
- The MongoDB adapter transforms application data for writing, assigns database identity, obtains the request session, calls Model.create, and converts/transforms the stored result back for reading unless returning is false.
- After persistence, createOperation sanitizes internal fields, optionally saves a version and sends verification email, runs field/collection afterRead and afterChange hooks, then cleans temporary files and commits its transaction.