Skip to content
Documentation
1.0.0-beta.9 · exact release

Hello JSON

Source fda16de1b352 · Published v1.0.0-beta.9

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

Terminal window
pulse doctor
pulse inspect
pulse test
pulse dev
pulse 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
}
}
]
}
ArtifactDefault build--experimental-native-sizeReduction
canonical-native.wasm2.3 KiB (2,353 bytes)2.2 KiB (2,270 bytes)3.5%

The executable documentation gate rebuilds and measures both variants on 1.0.0-beta.9. These are uncompressed on-disk sizes, not transfer sizes or platform limits.

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 },
},
}))
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' },
},
],
}