Kind: Function
Source: atloria-monorepo/apps/api/src/technical-docs/sanitize-jsonb.ts
Deep-sanitize a value before persisting it into a Postgres jsonb column.
Postgres jsonb cannot store the NUL character (U+0000) and chokes on other C0 control
characters. These leak in from parsed source (minified bundles, generated/binary-ish files)
and, at monorepo scale, a single bad byte deep in a multi-megabyte snapshot fails the whole
upsert with unexpected end of hex escape. Strip them (and lone UTF-16 surrogates, which are
not valid text) so the snapshot always persists. Tab / newline / carriage-return are kept.
Signature
tsfunction sanitizeForJsonb(value: T): T
Parameters
| Name | Type |
|---|---|
value | T |
Returns: T
Was this page helpful?