JSON and HTTP
The TypeScript facade accepts native bigint. HTTP and JSON boundaries must use
the exported wire codecs where monetary values appear.
Checkout input
Section titled “Checkout input”import { CheckoutCommandJson, createCheckout } from "@byfungsi/sapa";import { Effect, Schema } from "effect";
export const decodeAndCreateCheckout = (body: unknown) => Schema.decodeUnknownEffect(CheckoutCommandJson)(body, { onExcessProperty: "error", }).pipe(Effect.flatMap(createCheckout));The JSON body uses decimal strings for money. After decoding, SAPA receives
native bigint values.
Catalog input and output
Section titled “Catalog input and output”import { ProductCatalogJson, seedCatalog, type ProductCatalog,} from "@byfungsi/sapa";import { Effect, Schema } from "effect";
export const decodeAndSeedCatalog = (body: unknown) => Schema.decodeUnknownEffect(ProductCatalogJson)(body, { onExcessProperty: "error", }).pipe(Effect.flatMap(seedCatalog));
export const encodeCatalog = (catalog: ProductCatalog) => Schema.encodeSync(ProductCatalogJson)(catalog);Boundary checklist
Section titled “Boundary checklist”- Limit request body size before parsing. Provider notifications are bounded to 1 MiB by the facade, but reject oversized transport bodies earlier.
- Parse once at the edge and pass decoded values inward.
- Reject excess properties on commands.
- Use an authenticated server route for customer and beneficiary identities.
- Encode through the owning Schema before
JSON.stringify. - Never install a global
bigintJSON serializer.
SAPA does not publish HTTP routes. Your application owns routing, authentication, status codes, CORS, CSRF policy, and rate limiting.