Skip to content

Latest commit

 

History

History

README.md

Todo app (iii-sdk)

Todo REST API with streams, durable topics, and cron — migrated from the Motia todo-app example to iii-sdk@0.11.0 using the Motia → Node migration guide.

What this demonstrates

Area Pattern
HTTP registerFunction + registerTrigger with leading / paths, status_code responses, path_params, query_params
State iii.trigger({ function_id: 'state::get' | 'state::set' | 'state::delete' | 'state::list', ... })
Streams stream::set / stream::delete mirror on stream_name: 'todo', group_id: 'all-todos'
Queues iii::durable::publish + durable:subscriber triggers (notifications, analytics, completion workflow, achievements)
Cron 7-field expression: hourly stats, daily cleanup

No zod, no wrappers — plain iii.trigger() calls and TypeScript types.

Prerequisites

  • Bun
  • iii engine v0.11.x with iii-http, iii-state, iii-queue, iii-cron, iii-stream, iii-exec (see iii-config.yaml)

Quick start

cd quickstart/examples/todo-app
pnpm install --ignore-workspace
iii --config ./iii-config.yaml

The iii-exec worker launches bun run src/main.ts with watch on src/**/*.ts. HTTP listens on http://127.0.0.1:3000.

HTTP API

Method Path Function ID
POST /todos todo::create
GET /todos (optional ?status=) todo::list
GET /todos/:id todo::get
PATCH /todos/:id todo::update
DELETE /todos/:id todo::delete
GET /todo-stats todo::stats

Quick smoke test

bash test-todo-flow.sh

Example

curl -X POST http://127.0.0.1:3000/todos \
  -H 'content-type: application/json' \
  -d '{"title":"Buy milk","priority":"high"}'

Cron schedules

  • Hourly stats snapshot0 0 * * * * * (todo::daily-stats-cron)
  • Daily cleanup (archive completed > 7 days) — 0 0 0 * * * * (todo::cleanup-cron)

Durable topics

Same names as the original Motia flow: todo-created, todo-updated, todo-completed, todo-deleted, track-analytics, cleanup-completed, notification-sent, achievement-unlocked.

Production build

pnpm run build
pnpm run start

Swap the iii-exec command in iii-config.yaml to the bundled output for production.

License

Example code: Apache-2.0 (matches the rest of this monorepo outside engine/).