Skip to content

Examples

/examples/ contains runnable apps, focused API examples, live-provider examples, and fixtures used by the test suite. Start with the curated examples below when you want code to learn from. Use the full inventory when you need to find the evidence source for a specific feature.

If a row says "fixture", treat it as test evidence rather than a tutorial.

For a complete test-oriented inventory, see examples/README.md in the repository.

Start here

ExampleShows
framework-helloSloppy.create(), typed route param, JSON response
hello-minimalThe smallest runnable app
program-helloRoute-free Program Mode entrypoint
package-zod-likeInstalled package graph with a local file dependency

Routing

ExampleShows
framework-controllerController class + DI through static inject
framework-explicit-bindingRoute<T>, Query<T>, Body<T>, Header<> typed bindings
request-contextctx.route, ctx.query, ctx.request.headers, body parsing

Services and config

ExampleShows
framework-di-servicesSingleton/scoped/transient lifetimes through a request scope
config-basicaddObject, typed getters

Data

ExampleShows
framework-sqlite-crudTyped-handler SQLite CRUD with provider injection
framework-postgres-crudSame shape, PostgreSQL provider (needs a live database)
framework-sqlserver-crudSame shape, SQL Server provider (needs a live database)
orm-basicFirst-party sloppy/orm model, CRUD, relations, and migration script shape
orm-relations-includesOne-join and collection split-query includes
orm-cursor-exportORM cursor export to NDJSON chunks without materializing all rows
orm-migrationsCompiler-emitted ORM metadata and migration CLI output

Guide: Data streaming. APIs: Data and ORM.

Cache, Redis, and HTTP clients

ExampleShows
cache-basicMemory cache, cache-aside reads, schema validation, tag invalidation
cache-output-apiRoute output cache and HTTP cache headers
cache-hybrid-postgresMemory-fronted PostgreSQL distributed cache
redis-basicFirst-party Redis client, values, scripts, diagnostics, health
redis-cacheRedis-backed cache provider with tags and service registration
redis-locksRedis single-key lease shape
http-client-typedTyped named client registered through services
http-client-generatedOpenAPI-to-typed-client generation
http-client-resilienceRetry, circuit-breaker, bulkhead, and pool options
http-client-testhostTestHttp.mock() with TestHost outbound overrides

APIs: Cache, Redis, and HTTP Client.

Durable jobs

ExampleShows
jobs-basicSQLite durable queue, idempotency, redaction, worker run-once
jobs-recurringFive-field UTC cron schedules and manual recurring ticks
jobs-postgres-workerPostgreSQL-backed worker shape
jobs-sqlserver-workerSQL Server-backed worker shape
jobs-concurrency, jobs-concurrency-sqlite, jobs-concurrency-stepProvider-backed claim and lease behavior

Guide: Background tasks. API: Jobs.

Validation

ExampleShows
framework-validation-errorsSchema-backed body binding, Plan-level validation diagnostics

Rate limiting

ExampleShows
rate-limit-basicSliding-window IP limit on a public login route
rate-limit-authUser-partitioned limits on authenticated routes
rate-limit-redisDeclares RateLimit.redis(...) and its fail-closed behavior on main
rate-limit-testhostDeterministic windows under FakeClock
rate-limit-websocketWebSocket upgrade rate limiting

Guide: Rate limiting. API: RateLimit.

Webhooks

ExampleShows
webhooks-basicEvent descriptor, outbox registration, transactional publish, signed delivery wiring

Guide: Webhooks. Bootstrap test coverage: node tests/bootstrap/test_webhooks.mjs.

Static files

ExampleShows
static-files-basicapp.staticFiles("/assets", { root: "public", ... }) over a project-local directory
static-files-packageStatic assets carried into a packaged app artifact

Guide: Serve Static Assets. API: Static Files.

Background tasks and workers

ExampleShows
workers-background-serviceLong-running service alongside the HTTP server
workers-workqueueProducer/consumer queue with retry
workers-workerpoolBounded pool of worker isolates
workers-js-isolateSingle Worker.start isolate from a module path
workers-shutdownDrain-vs-cancel stop() behavior

Guide: Background tasks. API: Workers.

Stdlib (filesystem, network, OS, time, crypto, codec)

These are API-shape fixtures rather than full tutorials, but they are the shortest path to seeing each stdlib module in real source. Reference docs: Filesystem, Network, HTTP Client, OS, Time, Crypto, Codec.

ExampleShows
fs-basic, fs-streams, fs-watch, fs-roots-policysloppy/fs read/write, streaming handles, watchers, named-root paths
net-tcp-client, net-tcp-server, net-tcp-echo, net-deadline-cancelsloppy/net TCP client/server, deadlines, cancellation
net-local-ipc, net-policy-strictLocalEndpoint IPC; HTTP client origin policy
http-client-basicHttpClient outbound usage
os-runtime-api, core-process-time-codecsloppy/os System, Environment, Process.run/start, Signals
time-basic, time-deadline-cancellation, time-interval-schedule, time-fake-clocksloppy/time delays, deadlines, intervals, Time.fakeClock
crypto-random-token, crypto-hash-hmac, crypto-password, crypto-secret-constant-timesloppy/crypto randomness, hashing, HMAC, Argon2id, Secret
codec-base64-hex, codec-text-binary, codec-checksums, codec-compression, codec-streaming-compressionsloppy/codec encodings, binary I/O, gzip
core-fs-time-codec, core-network-time-codec, core-worker-timecombined stdlib usage with deadlines

How to run one

For a new project, prefer a template:

powershell
sloppy create my-api --template minimal-api
cd my-api
sloppy build
sloppy run .sloppy --once GET /health

Most curated examples have a README.md and a single source file. To run one through the dev path:

powershell
sloppy run examples/framework-hello/app.ts --once GET /hello/Ada

Or build first and run the artifacts:

powershell
sloppy build examples/framework-hello/app.ts --out .sloppy-tmp
sloppy run .sloppy-tmp --once GET /hello/Ada

sloppy run enters V8. Default non-V8 builds report the V8 requirement after compiling source input and writing artifacts; that diagnostic confirms the handoff path, but it is not positive handler execution.

Quick descriptions

framework-hello

Two routes, one typed parameter, deterministic JSON response. The example the Quickstart is built on. Good first run.

hello-minimal

The smallest possible app: Sloppy.create(), one route, one Results.text(...) response. Useful when something else stops working and you want to bisect.

program-hello

Route-free Program Mode source with main(args, ctx), relative module imports, arguments after --, and stdout.

package-zod-like

Installed package graph example that uses a local file: dependency. It is the smallest example for package resolution without depending on registry access.

framework-controller

Controller class with a static inject array, mapped via app.controller("/users", Controller, ...). Demonstrates DI without typed handler parameters.

framework-explicit-binding

Shows Route<T>, Query<T>, Body<T>, Header<"name"> type wrappers for explicit handler-parameter binding.

request-context

Exercises the source-input/native request context fields currently covered by the example: route params, query parsing, method, decoded path, and raw target. Headers and body helpers are covered by the broader runtime/test-host suites.

framework-di-services

Singleton, scoped, and transient services in a single app. Verifies that each lifetime behaves as documented.

config-basic

Loads config from addObject, reads with typed getters, demonstrates the SLOPPY:... key normalization.

framework-sqlite-crud

CRUD app using Sqlite<"main"> typed injection. The typed-handler version of the SQLite walkthrough.

framework-postgres-crud

Same shape, PostgreSQL provider. This optional provider example needs PostgreSQL client support and a running database. Normal Sloppy apps, the Quickstart, Program Mode, SQLite, templates, and package support do not need PostgreSQL or libpq. The example reads its connection string from Sloppy__Providers__postgres__main__connectionString. The compiler emits typed provider metadata/wrappers; live execution depends on the PostgreSQL bridge, provider config, and service setup.

framework-sqlserver-crud

Same shape, SQL Server provider. This optional provider example needs Microsoft ODBC Driver 17 or 18 and a connection string in Sloppy__Providers__sqlserver__main__connectionString. Normal Sloppy apps, the Quickstart, Program Mode, SQLite, templates, and package support do not need SQL Server or ODBC. The compiler emits typed provider metadata/wrappers; live execution depends on the SQL Server bridge, provider config, and driver support.

framework-validation-errors

A handler with a schema-typed Body<T>. Sends back structured application/problem+json validation errors when the body is malformed.

workers-background-service

A BackgroundService that runs alongside HTTP. Demonstrates start/stop hooks and cancellation through WorkerCancellationSignal.

workers-workerpool

A bounded worker isolate pool. Niche, but the pattern is canonical.

Complete example inventory

DirectoryCurrent role
codec-base64-hexCodec API-shape fixture
codec-checksumsCodec API-shape fixture
codec-compressionCodec API-shape fixture
codec-streaming-compressionCodec API-shape fixture
codec-text-binaryCodec API-shape fixture
compiler-helloCompiler/runtime conformance source
config-basicCurated config example
config-secrets-redactionConfig redaction fixture
config-strict-modeConfig strict-mode fixture
configured-apiCompiler/config conformance fixture
cache-basicMemory cache API-shape fixture
cache-hybrid-postgresHybrid cache example, live-provider gated
cache-output-apiOutput cache API-shape fixture
core-config-secretsCore integration fixture
core-fs-time-codecCore integration fixture
core-network-time-codecCore integration fixture
core-policy-auditCore integration fixture
core-process-time-codecCore integration fixture
core-worker-timeCore integration fixture
crypto-hash-hmacCrypto API-shape fixture
crypto-passwordCrypto API-shape fixture
crypto-random-tokenCrypto API-shape fixture
crypto-secret-constant-timeCrypto API-shape fixture
data-foundationData/capability API-shape fixture
dogfoodMachine-readable evidence catalog
ergonomicsAPI ergonomics fixture
framework-controllerCurated routing/controller example
framework-di-servicesCurated services example
framework-explicit-bindingCurated typed binding example
framework-helloCurated quickstart example
framework-postgres-crudLive PostgreSQL example
framework-sqlite-crudCurated SQLite CRUD example
framework-sqlserver-crudLive SQL Server example
framework-validation-errorsCurated validation example
fs-basicFilesystem API-shape fixture
fs-roots-policyFilesystem policy fixture
fs-streamsFilesystem streaming API-shape fixture
fs-watchFilesystem watch API-shape fixture
helloSmallest hello-app fixture used by app-host shape checks
hello-minimalMinimal runnable example
http-client-basicHTTP client API-shape fixture
http-client-generatedOpenAPI-to-typed-client documentation example
http-client-resilienceHTTP client resilience documentation example
http-client-testhostHTTP client TestHost mock documentation example
http-client-testhost-package-mockHTTP client package TestHost mock documentation example
http-client-typedTyped HTTP client documentation example
jobs-basicDurable jobs SQLite example
jobs-concurrencyDurable jobs concurrency example, live-provider gated
jobs-concurrency-sqliteDurable jobs SQLite concurrency example
jobs-concurrency-stepDurable jobs process-step concurrency example
jobs-postgres-workerDurable jobs PostgreSQL worker example, live-provider gated
jobs-recurringDurable recurring jobs example
jobs-sqlserver-workerDurable jobs SQL Server worker example, live-provider gated
jobs-stressDurable jobs stress example
modules-apiCompiler module conformance fixture
modules-basicModule API-shape fixture
net-deadline-cancelNetwork cancellation fixture
net-local-ipcLocal IPC API-shape fixture
net-policy-strictNetwork policy fixture
net-tcp-clientTCP client API-shape fixture
net-tcp-echoTCP echo API-shape fixture
net-tcp-serverTCP server API-shape fixture
os-runtime-apiOS API-shape fixture
orm-basicORM documentation example
orm-cursor-exportORM cursor export documentation example
orm-migrationsORM migration tooling fixture
orm-relations-includesORM relations/include documentation example
orm-testservicesORM TestServices documentation example
postgres-basicPostgreSQL provider fixture, live-provider gated
control-planeLarger app-style coverage example for routing, data, diagnostics, and tooling
rate-limit-authAuthenticated-user rate-limit example
rate-limit-basicSliding-window IP rate-limit example
rate-limit-redisDistributed rate-limit adapter declaration (fails closed on main)
rate-limit-testhostRate-limit windows under FakeClock
rate-limit-websocketWebSocket upgrade rate limiting
redis-basicRedis client example, live-provider gated
redis-cacheRedis-backed cache example, live-provider gated
redis-locksRedis lock example, live-provider gated
request-contextCurated request context example
sqlite-basicSQLite provider fixture
sqlserver-basicSQL Server provider fixture, live-provider gated
static-files-basicapp.staticFiles over a project-local directory
static-files-packageStatic assets carried into a packaged app artifact
webhooks-basicWebhook event descriptor, outbox registration, transactional publish, signed delivery
time-basicTime API-shape fixture
time-deadline-cancellationTime cancellation fixture
time-fake-clockTime fake-clock fixture
time-interval-scheduleTime interval/schedule fixture
users-api-sqliteSQLite source-input conformance example
validation-errorsCompiler validation fixture
workers-background-serviceCurated worker service example
workers-js-isolateWorker isolate API-shape fixture
workers-shutdownWorker shutdown fixture
workers-workerpoolCurated worker pool example
workers-workqueueWorker queue fixture

Public alpha. APIs and artifact formats may still change between alpha revisions.