Ejemplo
@hono/node-server 2.1.0: serve
Muestra verificada para npm @hono/node-server 2.1.0: serve. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.
sha256:0c294e68ac37d664840045ec5b18ee4bc7788c70633258f6a720c64e6451fc4f
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-01 |
Caso
HOW- Objetivo
- verify serve in pkg:npm/%40hono/node-server@2.1.0
- Paquetes
- Símbolos
-
- serve
- Entorno
- node 22.23.2
- Creado
- 2026-09-01T22:29:32Z
Contrato
- @hono/node-server exports serve function
- serve starts an HTTP server and returns an http.Server instance
- serve invokes listeningListener with server AddressInfo including port and address
- serve dispatches HTTP GET requests to fetch handler and responds with status, headers, and body
- serve dispatches HTTP POST requests with JSON payload to fetch handler
- serve supports custom createServer factory function in options
- serve HTTP server can be closed via server.close()
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código fuente
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 serve in pkg:npm/%40hono/node-server@2.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40hono/node-server@2.1.0
Demonstrate these symbols/APIs:
- serve
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.
{"case":{"caseId":"case:sha256:8a42e6ed0f241dda40e3986de00c20659340b2a05b51b261a0454271cf71921c","contract":["@hono/node-server exports serve function","serve starts an HTTP server and returns an http.Server instance","serve invokes listeningListener with server AddressInfo including port and address","serve dispatches HTTP GET requests to fetch handler and responds with status, headers, and body","serve dispatches HTTP POST requests with JSON payload to fetch handler","serve supports custom createServer factory function in options","serve HTTP server can be closed via server.close()"],"goal":"verify serve in pkg:npm/%40hono/node-server@2.1.0","kind":"HOW","packages":["pkg:npm/%40hono/node-server@2.1.0"],"schemaVersion":1,"symbols":["serve"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40hono/node-server@2.1.0"],"schemaVersion":1,"subject":"pkg:npm/%40hono/node-server@2.1.0","symbols":["serve"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-hono-node-server-serve",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-hono-node-server-serve",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@hono/node-server": "2.1.0"
}
},
"node_modules/@hono/node-server": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.0.tgz",
"integrity": "sha512-XovyyCCnBzW+zKu+z/zq8hwNs4KOR5rEMAOxo2f40Q5xoOI37IMm6MIg2COOUtUApo0i6850MTBKH2u4QLGIqg==",
"license": "MIT",
"engines": {
"node": ">=20"
},
"peerDependencies": {
"hono": "^4"
}
},
"node_modules/hono": {
"version": "4.13.5",
"resolved": "https://registry.npmjs.org/hono/-/hono-4.13.5.tgz",
"integrity": "sha512-O6+/eCYRkzzzy0rPWwKLiGBR1nFuUPZynnwjxN1MBA62NNqbT0wQEzQyK2gSO5yDIDB336sXQleAhOHrzlYyKw==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=16.9.0"
}
}
}
}
{
"name": "sample-hono-node-server-serve",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"dependencies": {
"@hono/node-server": "2.1.0"
}
}
{
"schemaVersion": 1,
"goal": "verify serve in pkg:npm/%40hono/node-server@2.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40hono/node-server@2.1.0"
],
"symbols": [
"serve"
]
}
import assert from 'node:assert/strict';
import http from 'node:http';
import { serve, createAdaptorServer } from '@hono/node-server';
// Contract 1: @hono/node-server exports serve function
{
assert.strictEqual(typeof serve, 'function');
assert.strictEqual(typeof createAdaptorServer, 'function');
}
// Contract 2: serve starts an HTTP server and returns an http.Server instance
// Contract 3: serve invokes listeningListener with server AddressInfo including port and address
// Contract 4: serve dispatches HTTP GET requests to fetch handler and responds with status, headers, and body
// Contract 5: serve dispatches HTTP POST requests with JSON payload to fetch handler
{
let listeningInfo = null;
const server = serve(
{
fetch: async (req) => {
const url = new URL(req.url);
if (url.pathname === '/test') {
return new Response(JSON.stringify({ ok: true, method: req.method }), {
status: 200,
headers: { 'content-type': 'application/json' },
});
}
if (url.pathname === '/echo' && req.method === 'POST') {
const body = await req.json();
return new Response(JSON.stringify({ received: body }), {
status: 201,
headers: { 'content-type': 'application/json' },
});
}
return new Response('Not Found', { status: 404 });
},
port: 0,
hostname: '127.0.0.1',
},
(info) => {
listeningInfo = info;
}
);
assert.ok(server instanceof http.Server);
await new Promise((resolve) => {
if (server.listening) resolve();
else server.once('listening', resolve);
});
const address = server.address();
assert.ok(address && typeof address === 'object');
assert.strictEqual(typeof address.port, 'number');
assert.strictEqual(address.address, '127.0.0.1');
assert.deepStrictEqual(listeningInfo, address);
const baseUrl = `http://127.0.0.1:${address.port}`;
// GET request
const getRes = await fetch(`${baseUrl}/test`);
assert.strictEqual(getRes.status, 200);
assert.strictEqual(getRes.headers.get('content-type'), 'application/json');
const getData = await getRes.json();
assert.deepStrictEqual(getData, { ok: true, method: 'GET' });
// POST request
const postRes = await fetch(`${baseUrl}/echo`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ message: 'hono-node-server' }),
});
assert.strictEqual(postRes.status, 201);
const postData = await postRes.json();
assert.deepStrictEqual(postData, { received: { message: 'hono-node-server' } });
// 404 Not Found
const notFoundRes = await fetch(`${baseUrl}/missing`);
assert.strictEqual(notFoundRes.status, 404);
// Contract 7: serve HTTP server can be closed via server.close()
await new Promise((resolve, reject) => {
server.close((err) => (err ? reject(err) : resolve()));
});
assert.strictEqual(server.listening, false);
}
// Contract 6: serve supports custom createServer factory function in options
{
let customFactoryCalled = false;
const server = serve({
fetch: () => new Response('custom factory response'),
port: 0,
hostname: '127.0.0.1',
createServer: (options, listener) => {
customFactoryCalled = true;
return http.createServer(options, listener);
},
});
assert.strictEqual(customFactoryCalled, true);
assert.ok(server instanceof http.Server);
await new Promise((resolve) => {
if (server.listening) resolve();
else server.once('listening', resolve);
});
const address = server.address();
const res = await fetch(`http://127.0.0.1:${address.port}/`);
assert.strictEqual(res.status, 200);
const text = await res.text();
assert.strictEqual(text, 'custom factory response');
await new Promise((resolve, reject) => {
server.close((err) => (err ? reject(err) : resolve()));
});
assert.strictEqual(server.listening, false);
}
console.log('All @hono/node-server serve contract tests passed.');
Seeder de origen
anónimo