Zod schemas and TypeScript types for all data the Hungr API sends and receives. The API validates requests with these schemas and generates its OpenAPI spec from them.
It's a workspace package, not published to npm. From the repository root, add it to another workspace (here apps/vendor) and build it:
npm pkg set "dependencies.@hungr/types=*" -w apps/vendor
npm install
npm run build -w @hungr/types
Rebuild it after every change, since apps import the compiled dist/. Use * rather than npm install @hungr/types, which saves ^0.1.0 and stops resolving once the version moves past 0.1.x.
import { VendorSchema, type Vendor } from "@hungr/types"
const vendor: Vendor = VendorSchema.parse(await res.json())
Each resource X has a schema XSchema and a type X, plus CreateX and UpdateX for request bodies, XFilter for list queries and XList for a page of results. IDs are strings, dates are ISO 8601 strings, and money is an integer number of NZD cents.
From the repository root:
| Command | What it does |
|---|---|
npm run build -w @hungr/types |
Compiles to dist/ |
npm test -w @hungr/types |
Runs the schema tests |
npm run docs -w @hungr/types |
Builds the types docs into docs/ (needs Node 22.18 or newer) |