Skip to content
Documentation
1.0.0-beta.10 · latest

Hello JSON

Source e69e4b6f1381 · Published v1.0.0-beta.10

The smallest canonical Pulse project: branch on the request path and return JSON or text.

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 app
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 },
},
}))

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.

RequestExpected response
health
GET /health
{"status":200,"json":{"ok":true}}
hello
GET /hello
{"status":200,"json":{"message":"hello from Pulse"}}
missing
GET /missing
{"status":404,"text":"not found"}
Terminal window
npm run inspect

Inspect describes the configured Node Native target and the recognized response capabilities. This is a selected JSON excerpt; paths, hashes and other fields are omitted.

Terminal window
npm run inspect -- --json
{
"status": "ok",
"project": { "target": "native" },
"provider": { "id": "node" },
"compiler": { "capabilities": ["response.json", "response.text"] }
}
Terminal window
npm run doctor

Doctor 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.

Terminal window
npm run doctor -- --json
{
"status": "passed",
"summary": { "warnings": 0, "failed": 0 }
}

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.

Terminal window
npm run build -- --out .pulse-docs-build
npm 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:

Terminal window
npm exec -- pulse report --artifact .pulse-docs-build/pulse-build.json --html

Reports 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.

Open full report · Capture provenance

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.

Terminal window
npm test
npm run dev

While the foreground server is running, request http://127.0.0.1:8787/health or /hello. Stop it with Ctrl+C before building:

Terminal window
npm run build

The documented test result below is executed by the documentation gate.

Terminal window
pulse test --json
{
"status": "passed",
"provider": "node",
"summary": {
"total": 3,
"passed": 3,
"failed": 0
},
"cases": [
{
"name": "health",
"status": "passed",
"response": {
"status": 200
}
}
]
}
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' },
},
],
}

For build settings, see Native build optimization.

ArtifactDefault build
Portable guest canonical-native.wasm2.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.