SMOZ is a small, pragmatic toolkit for authoring AWS Lambda handlers with [Middy] and [Zod], then aggregating Serverless functions and hand‑crafted OpenAPI 3.1 paths from a single, schema‑first application definition.
- Keep prod code testable and framework‑agnostic
- HTTP middleware with validation, shaping, errors, CORS, negotiation, and HEAD
- Non‑HTTP flows stay lean (no middleware overhead)
From an empty directory:
npx -p @karmaniverous/get-dotenv@^8.0.0 -p @karmaniverous/smoz smoz init
npx smoz dev -p 3000- The first command scaffolds a new app and installs its dependencies, including a local
smozbin and@karmaniverous/get-dotenv, which the bin needs. - The second command starts the inline local backend and keeps registers + OpenAPI fresh.
- Open http://localhost:3000/openapi in your browser.
Prefer serverless‑offline?
npx smoz dev -l offline -p 3000Add your first endpoint (avoid clashing with the template’s hello):
npx smoz add rest/foo/get- Overview
- Why smoz?
- Getting started
- 10-minute tour
- HTTP Middleware
- Recipes
- Templates
- CLI
- Contributing
npm i @karmaniverous/smoz zod zod-openapi
npm i -D @karmaniverous/get-dotenv@^8.0.0@karmaniverous/get-dotenv (^8.0.0) is an optional peer dependency: the smoz CLI needs it, your Lambda code doesn’t. Without it, smoz prints how to install it and exits 1.
zod-openapi (^6) and @serverless/typescript (^4.30) are optional peer dependencies: SMOZ's type declarations import their types. Install @serverless/typescript as a dev dependency when you type serverless.ts or a function's serverless config (the template does).
npm i -D typescript typescript-eslint eslint prettier typedoc