@podosoft/podokit-contracts
v0.4.0
Published
Shared PodoKit contracts: capability flags, the REST error envelope, and stable error codes used by both the NestJS backend and the SvelteKit frontend.
Readme
@podosoft/podokit-contracts
Shared contracts for PodoKit apps — the pieces the NestJS backend and the SvelteKit frontend must agree on, in one place so they cannot drift:
Capabilities— feature flags and public authentication policy values, including the optional session idle timeout, reported atGET /account/capabilities.ErrorEnvelope/ErrorBody— the standard non-2xx response shape.AppException— backend exception carrying a stablecode.SIGNUP_APPROVAL_REQUIRED— the stable pending-registration error code.PUBLIC_SIGNUP_DISABLED— the stable closed-registration error code.PROFILE_IMAGE_POLICY/ProfileImageResponse— the shared profile-image limits and upload/remove response.PROFILE_IMAGE_*— stable profile-image validation and lookup error codes.
Pure types and small classes, zero runtime dependencies.
Install
npm install @podosoft/podokit-contractsUsage
import { AppException, type Capabilities, type ErrorEnvelope } from "@podosoft/podokit-contracts";
// backend: throw with a stable, language-independent code
throw new AppException("EMAIL_TAKEN", "That email is already registered", 409);
// frontend: branch on error.code, not the messageMost apps get these through the generated code and @podosoft/podokit-api-client
rather than importing this package directly.
License
Apache-2.0
