npx @karmaniverous/smoz init -i
npx smoz dev -p 3000
smoz
bin).Offline option (serverless‑offline):
npx smoz dev -l offline -p 3000
Add your first endpoint:
npx smoz add rest/foo/get
npm i @karmaniverous/smoz zod zod-openapi
Dev tooling (recommended):
npm i -D typescript typescript-eslint eslint prettier typedoc
npx smoz init --yes
This scaffolds:
Optional defaults (smoz.config.json):
cliDefaults.init
— set template
, onConflict
, and install
cliDefaults.dev.local
— set default local mode (inline
|offline
)npx smoz register
npm run openapi
openapi
will:
app/generated/register.openapi.ts
app.buildAllOpenApiPaths()
app/generated/openapi.json
Use the dev loop to keep registers/OpenAPI fresh and (optionally) serve HTTP:
npx smoz dev
See the CLI page for flags and inline/offline details. Inline is the default backend for --local; use --local offline
to run serverless-offline instead.
npm run package # no deploy
# or
npm run deploy
Serverless picks up:
functions
from app.buildAllServerlessFunctions()
app.environment
app.stages
// app/functions/rest/hello/get/lambda.ts
import { dirname, join } from 'node:path'; // example for path helpers
import { z } from 'zod';
import { app } from '@/app/config/app.config';
export const responseSchema = z.object({ ok: z.boolean() });
export const fn = app.defineFunction({
functionName: 'hello_get',
eventType: 'rest',
httpContexts: ['public'],
method: 'get',
basePath: 'hello',
contentType: 'application/json',
responseSchema,
callerModuleUrl: import.meta.url,
endpointsRootAbs: dirname(new URL('../..', import.meta.url).pathname),
});
// app/functions/rest/hello/get/handler.ts
import type { z } from 'zod';
import type { responseSchema } from './lambda';
import { fn } from './lambda';
type Response = z.infer<typeof responseSchema>;
export const handler = fn.handler(
async () => ({ ok: true }) satisfies Response,
);
// app/functions/rest/hello/get/openapi.ts
import { fn, responseSchema } from './lambda';
fn.openapi({
summary: 'Hello',
description: 'Return a simple OK payload.',
responses: {
200: {
description: 'Ok',
content: { 'application/json': { schema: responseSchema } },
},
},
tags: ['public'],
});
Re‑generate:
npx smoz register
npm run openapi
npm run stan:build
in the smoz repo so editors resolve @karmaniverous/smoz
types across templates.prettier/prettier
: error). Use:npm run lint:fix
npm run templates:lint
npm run typecheck
npm run templates:typecheck