The smallest canonical Pulse project: branch on the request path and return JSON or text.
Handler
Section titled “Handler”import { Pulse } from '@pulse-compute/pulse'
const app = new Pulse({ auto: true })
app.get('/health', async (ctx) => ctx.json({ ok: true }))app.get('/hello', async (ctx) => ctx.json({ message: 'hello from Pulse' }))app.get('/*', async (ctx) => ctx.text('not found', { status: 404 }))
export default appProject config
Section titled “Project config”import { defineConfig } from '@pulse-compute/pulse'
export default defineConfig((_scope) => ({ pulse: { entry: 'src/index.ts', tests: 'tests/pulse.harness.ts', defaultProfile: 'local', strict: true, }, local: { host: 'node', target: 'native', outDir: 'dist', dev: { host: '127.0.0.1', port: 8787 }, },}))Request and response
Section titled “Request and response”Generated from the executable test harness below; these are tested requests or event frames, not an exhaustive application specification. Expected errors and emitted events are included; fixtures and provider setup remain in the harness.
| Request | Expected response |
|---|---|
healthGET /health | {"status":200,"json":{"ok":true}} |
helloGET /hello | {"status":200,"json":{"message":"hello from Pulse"}} |
missingGET /missing | {"status":404,"text":"not found"} |
Inspect
Section titled “Inspect”npm run inspectInspect describes the configured Node Native target and the recognized response capabilities. This is a selected JSON excerpt; paths, hashes and other fields are omitted.
npm run inspect -- --json{ "status": "ok", "project": { "target": "native" }, "provider": { "id": "node" }, "compiler": { "capabilities": ["response.json", "response.text"] }}Doctor
Section titled “Doctor”npm run doctorDoctor checks the project and its local toolchain before execution. This selected result is checked by the documentation gate; it is not a promise about another machine.
npm run doctor -- --json{ "status": "passed", "summary": { "warnings": 0, "failed": 0 }}Report
Section titled “Report”Build into a separate directory, then review the retained evidence. The report reads the completed artifact without rebuilding or running the application. This selected excerpt accounts for all three registered handlers in the build evidence; timings, paths, hashes and optional evidence are deliberately not presented as stable output.
npm run build -- --out .pulse-docs-buildnpm exec -- pulse report --artifact .pulse-docs-build/pulse-build.json --json{ "kind": "pulse.application-report", "reportVersion": 1, "analytics": { "coverage": { "handlers": { "expected": 3, "observed": 3, "status": "complete" } } }}Optional offline HTML uses the same retained artifact:
npm exec -- pulse report --artifact .pulse-docs-build/pulse-build.json --htmlReports are build-review artifacts; review their contents before sharing. Missing, stale or incompatible evidence is an error, not permission to invent a report.
Interactive report captured from this example at source e69e4b6f1381. Build evidence describes this captured build, not a runtime guarantee.
Workflow
Section titled “Workflow”Run commands from this example directory after installing the repository dependencies. The npm scripts use the project-local CLI; Inspect and Doctor commands are shown with their results above.
npm testnpm run devWhile the foreground server is running, request http://127.0.0.1:8787/health
or /hello. Stop it with Ctrl+C before building:
npm run buildTest result
Section titled “Test result”The documented test result below is executed by the documentation gate.
pulse test --json{ "status": "passed", "provider": "node", "summary": { "total": 3, "passed": 3, "failed": 0 }, "cases": [ { "name": "health", "status": "passed", "response": { "status": 200 } } ]}Test harness
Section titled “Test harness”export default { cases: [ { name: 'health', request: { path: '/health' }, expect: { status: 200, json: { ok: true } }, }, { name: 'hello', request: { path: '/hello' }, expect: { status: 200, json: { message: 'hello from Pulse' }, }, }, { name: 'missing', request: { path: '/missing' }, expect: { status: 404, text: 'not found' }, }, ],}Wasm size
Section titled “Wasm size”For build settings, see Native build optimization.
| Artifact | Default build |
|---|---|
Portable guest canonical-native.wasm | 2.2 KiB (2,273 bytes) |
The executable documentation gate rebuilds and measures the default artifact. Measured with Node 24.18.0 and lockfile-pinned AssemblyScript 0.28.18. These are uncompressed on-disk sizes, not transfer sizes or platform limits.