Pulse 1.0.0-beta.1 betaExact, immutable release documentation.Browse latest
Documentation platform maintainersactiveReviewed 2026-08-01Review by 2027-01-12

Request schema#

Compiles explicit TypeScript request and response schemas with the project. The same codecs are used by test, dev, Node builds, and Fastly builds.

Workflow#

pulse doctor
pulse inspect
pulse test
pulse dev
pulse build

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

pulse test --json
{
  "status": "passed",
  "provider": "node",
  "summary": {
    "total": 2,
    "passed": 2,
    "failed": 0
  },
  "cases": [
    {
      "name": "create-user",
      "status": "passed",
      "response": {
        "status": 201
      }
    }
  ]
}

Wasm size#

ArtifactDefault build--experimental-native-sizeReduction
canonical-native.wasm38.9 KiB (39,795 bytes)30.8 KiB (31,578 bytes)20.6%

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

Handler#

import { Pulse } from '@pulse-compute/pulse'
import type { CreateUserInput, CreateUserOutput } from './schemas.js'

const app = new Pulse({ auto: true })

app.post('/users', async (ctx) => {
  const first = await ctx.req.json<CreateUserInput>('app.CreateUserInput')
  const second = await ctx.req.json<CreateUserInput>('app.CreateUserInput')
  const output: CreateUserOutput = {
    id: 7,
    name: first.name,
    active: first.active,
    sameReference: first === second,
  }
  return ctx.json(output, { status: 201, schema: 'app.CreateUserOutput' })
})

export default app

Project config#

import { defineConfig } from '@pulse-compute/pulse'

export default defineConfig((_scope) => ({
  pulse: {
    entry: 'src/index.ts',
    schema: 'src/schemas.ts',
    tests: 'tests/pulse.harness.ts',
    defaultProfile: 'local',
    strict: true,
  },
  local: {
    host: 'node',
    target: 'native',
    outDir: 'dist',
    schemas: { contentTypePolicy: 'require-json', maxBytes: 1024 },
  },
}))

Test harness#

export default {
  cases: [
    {
      name: 'create-user',
      request: {
        method: 'POST',
        path: '/users',
        headers: { 'content-type': 'application/json' },
        body: JSON.stringify({ name: 'Ada', active: true }),
      },
      expect: {
        status: 201,
        json: {
          id: 7,
          name: 'Ada',
          active: true,
          sameReference: true,
        },
      },
    },
    {
      name: 'invalid-user',
      request: {
        method: 'POST',
        path: '/users',
        headers: { 'content-type': 'application/json' },
        body: JSON.stringify({ name: 12, active: true }),
      },
      expect: {
        error: {
          name: 'SchemaDecodeError',
          code: 'PULSE_SCHEMA_DECODE',
        },
      },
    },
  ],
}
Browse other documentation