2.3 KiB
2.3 KiB
Application productivity kit
WrNexus applications should declare infrastructure once and keep only domain decisions locally.
Included foundations
- HTTP routes:
defineApiRoute,authorized,requireUser,requirePermission,requireParam,requireJson, andjson. - CRUD resources:
defineResourcegenerates owned list/create/get/update/delete handlers. - Seed data:
addSeedData,upsertSeedData,seedIfMissing,defineSeed,removeSeedData, andrunSeedQuery. - Transactional delivery:
withOutbox,drainOutbox, andinstallOutboxSchema. - Job state transitions:
defineJobStateMachine. - SQLite/PostgreSQL/MySQL queue tables: configured storage plus
databaseQueueStore. - Queue operations: success/failed hooks, dashboard handler and queue CLI.
- Queue testing:
testQueuewith deterministicrunNext/runAll. - Workflows and compensation: durable workflows and
defineSaga. - Mail:
defineMail,defineMailTemplate, sandbox allowlists andqueuedMail. - Encrypted settings:
defineSecretResource. - Ledgers:
defineLedgerwith atomic debit and audit entries. - Forms:
useFormfor values, errors, dirty/submitting state, validation and submission. - Typed HTTP calls:
createApiClient; generated OpenAPI/SDK clients remain available throughwrnexus api generate. - Full-stack testing:
createTestApp, database rollback/factories, and queue test controls. - Package migrations: queue/auth/authz packages contribute migrations through the plugin lifecycle.
- Auth/OAuth: auth and authz plugins own routes, middleware, roles and provider lifecycle.
- Code generation:
wrnexus generate resource <name>. - Incremental features:
wrnexus add queue|mail|seed|testing|resource. - Starter presets:
wrnexus create app --preset=saas|emailand--features=....
Recommended new-project flow
wrnexus create acme --preset=saas
cd acme && bun install
wrnexus generate resource projects
wrnexus add mail
wrnexus db migrate
wrnexus db seed
wrnexus dev
Use generated resources for ordinary owned CRUD. Use the outbox for business operations that change data and enqueue work together. Use sagas only when a workflow crosses systems that cannot share a transaction. Application code should retain product-specific policy; framework code owns storage, validation, lifecycle, retries, diagnostics and scaffolding.