CodeSampleX

Sample

hono 4.13.7: Hono

Verified sample for npm hono 4.13.7: Hono. The contract ran on node 22 · linux debian/x64 · docker and passed: hono.Hono is exported as a constructor class…

sha256:5f6a88b281ce7f70addf93f256b4725dafc6869b5bcdb59bc7e2b02f26d10494

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-06

Case

HOW
Goal
verify pkg:npm/hono@4.13.7
Packages
Symbols
  • hono.Hono
Environment
node 22.23.2
Created
2026-09-06T03:33:10Z

Contract

  1. hono.Hono is exported as a constructor class from hono
  2. Hono instance handles GET routes with middleware context and custom headers
  3. Hono instance extracts path parameters and query parameters from request context
  4. Hono instance processes POST requests with JSON payload and returns structured response
  5. Hono mounts sub-applications using route method preserving nested path prefixes
  6. Hono instance returns 404 response for unmatched routes

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:npm/hono@4.13.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/hono@4.13.7
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:36434f4c0c00e8f671a2838e997ef640f7c566d9cb1cf2c5af07746a6ed95c76","constraints":{"executionContext":"node"},"contract":["hono.Hono is exported as a constructor class from hono","Hono instance handles GET routes with middleware context and custom headers","Hono instance extracts path parameters and query parameters from request context","Hono instance processes POST requests with JSON payload and returns structured response","Hono mounts sub-applications using route method preserving nested path prefixes","Hono instance returns 404 response for unmatched routes"],"goal":"verify pkg:npm/hono@4.13.7","kind":"HOW","packages":["pkg:npm/hono@4.13.7"],"schemaVersion":1,"symbols":["hono.Hono"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/hono@4.13.7"],"schemaVersion":1,"subject":"pkg:npm/hono@4.13.7","symbols":["hono.Hono"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-hono-core",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-hono-core",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "hono": "4.13.7"
      }
    },
    "node_modules/hono": {
      "version": "4.13.7",
      "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.7.tgz",
      "integrity": "sha512-c8/gF9ac8Y78/agExVocyLevgR+JlpNB444Py0FSX8pJoPdYUfUzRcXtYEYGwt6l19qIlVZPN5Mfsw9jFShmQQ==",
      "license": "MIT",
      "engines": {
        "node": ">=16.9.0"
      }
    }
  }
}
package.json
{
  "name": "sample-hono-core",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of hono.Hono in pkg:npm/hono@4.13.7",
  "main": "src/index.js",
  "dependencies": {
    "hono": "4.13.7"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/hono@4.13.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/hono@4.13.7"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const { Hono } = require('hono');

/**
 * Creates and configures a clean-room Hono application instance.
 * @returns {Hono} Configured Hono application.
 */
function createApp() {
  const app = new Hono();

  // Middleware: sets context variable and custom response header
  app.use('*', async (c, next) => {
    c.set('traceId', 'trace-hono-4137');
    await next();
    c.header('X-App-Framework', 'Hono');
  });

  // GET route with context variable and custom header
  app.get('/api/health', (c) => {
    const traceId = c.get('traceId');
    return c.json({ status: 'healthy', traceId });
  });

  // Route with path parameter and query parameter
  app.get('/api/items/:id', (c) => {
    const id = c.req.param('id');
    const filter = c.req.query('filter') || 'all';
    return c.json({ id, filter });
  });

  // POST route parsing JSON body
  app.post('/api/items', async (c) => {
    const body = await c.req.json();
    return c.json({ created: true, item: body }, 201);
  });

  // Sub-application mounted via app.route
  const subApp = new Hono();
  subApp.get('/info', (c) => {
    return c.json({ module: 'sub-service' });
  });
  app.route('/api/nested', subApp);

  return app;
}

module.exports = {
  Hono,
  createApp
};
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { Hono, createApp } = require('../src/index.js');

// Contract 1: hono.Hono is exported as a constructor class from hono
{
  assert.strictEqual(typeof Hono, 'function', 'Hono must be a function/constructor');
  const instance = new Hono();
  assert.ok(instance instanceof Hono, 'new Hono() creates an instance of Hono');
  assert.strictEqual(typeof instance.fetch, 'function', 'Hono instance must implement fetch');
  assert.strictEqual(typeof instance.request, 'function', 'Hono instance must implement request');
  assert.strictEqual(typeof instance.get, 'function', 'Hono instance must implement get');
  assert.strictEqual(typeof instance.post, 'function', 'Hono instance must implement post');
  assert.strictEqual(typeof instance.use, 'function', 'Hono instance must implement use');
  assert.strictEqual(typeof instance.route, 'function', 'Hono instance must implement route');

  // Verify pinned package version
  const honoEntryUrl = import.meta.resolve('hono');
  const pkgJsonPath = fileURLToPath(new URL('../package.json', honoEntryUrl));
  assert.ok(fs.existsSync(pkgJsonPath));
  const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
  assert.strictEqual(pkgJson.name, 'hono');
  assert.strictEqual(pkgJson.version, '4.13.7');
}

// Contract 2: Hono instance handles GET routes with middleware context and custom headers
{
  const app = createApp();
  const req = new Request('http://localhost/api/health');
  const res = await app.fetch(req);

  assert.strictEqual(res.status, 200, 'GET /api/health returns HTTP 200');
  assert.strictEqual(res.headers.get('x-app-framework'), 'Hono', 'Middleware sets custom header');
  const data = await res.json();
  assert.deepStrictEqual(data, {
    status: 'healthy',
    traceId: 'trace-hono-4137'
  });
}

// Contract 3: Hono instance extracts path parameters and query parameters from request context
{
  const app = createApp();
  const req = new Request('http://localhost/api/items/item-101?filter=active');
  const res = await app.fetch(req);

  assert.strictEqual(res.status, 200, 'GET /api/items/item-101 returns HTTP 200');
  const data = await res.json();
  assert.deepStrictEqual(data, {
    id: 'item-101',
    filter: 'active'
  });
}

// Contract 4: Hono instance processes POST requests with JSON payload and returns structured response
{
  const app = createApp();
  const payload = { title: 'Sample item', count: 5 };
  const req = new Request('http://localhost/api/items', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(payload)
  });
  const res = await app.fetch(req);

  assert.strictEqual(res.status, 201, 'POST /api/items returns HTTP 201 Created');
  const data = await res.json();
  assert.deepStrictEqual(data, {
    created: true,
    item: payload
  });
}

// Contract 5: Hono mounts sub-applications using route method preserving nested path prefixes
{
  const app = createApp();
  const req = new Request('http://localhost/api/nested/info');
  const res = await app.fetch(req);

  assert.strictEqual(res.status, 200, 'Mounted sub-app responds on prefixed path');
  const data = await res.json();
  assert.deepStrictEqual(data, { module: 'sub-service' });
}

// Contract 6: Hono instance returns 404 response for unmatched routes
{
  const app = createApp();
  const req = new Request('http://localhost/non-existent-endpoint');
  const res = await app.fetch(req);

  assert.strictEqual(res.status, 404, 'Unmatched route returns HTTP 404 Not Found');
}

console.log('CONTRACT PASS: All hono.Hono contract assertions passed.');

Origin Seeder

anonymous