npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shukoi/api

v1.0.4

Published

Hono REST router, stream-bounded chunked reader, OpenAPI 3.1.0 generator, and RFC 9457 Problem Details for Shukoi.

Readme

@shukoi/api

Protocol Module A: Hono REST Router, OpenAPI 3.1.0 Generator & Stream-Bounded Reader

npm version License: MIT Pure Web Standard

@shukoi/api exposes declarative Shukoi actions over standard HTTP REST interfaces powered by Hono. It automatically compiles synchronized OpenAPI 3.1.0 specifications directly from frozen TypeBox schemas, enforces chunked transfer OOM defenses, handles multi-value array query parameters, and serializes operational failures to RFC 9457 Problem Details (application/problem+json).


Key Features & Invariants

  • Auto-Generated OpenAPI 3.1.0 Documentation: Automatically compiles frozen action schemas into a living OpenAPI 3.1 specification at /openapi.json. Automatically extracts query parameters for GET and DELETE operations, registers components.securitySchemes (bearerAuth and apiKeyAuth), sets operation security requirements on authenticated actions, and defines root servers: [{ url: '/' }].
  • Stream-Level Bounded Ingress (readBoundedJsonStream): Reads chunked HTTP streams chunk-by-chunk with a cumulative byte counter. If received bytes exceed config.limits.maxBodyBytes, the reader is immediately cancelled and throws HTTP 413 without buffering the remainder into memory.
  • Deterministic Parameter Merge Priority: Strict merge priority guarantees that path variables (:id) always take precedence: $$\text{Query Params} < \text{JSON Body} < \text{Path Params}$$ Path parameters can never be overwritten or poisoned by body fields or query strings.
  • Universal RFC 9457 Problem Details: All runtime errors, validation failures (422), authentication rejections (401/403), payload size breaches (413), and unmapped routes (404 via app.notFound()) return standard application/problem+json envelopes with type, title, status, detail, code, instance, and requestId.
  • Safe Primitive Coercion: Coerces string query parameters into numbers and booleans safely, while strictly preserving leading-zero numeric strings (e.g. "01234", "007") as strings to prevent validation corruption on postal codes, NIK, or phone numbers.
  • Multi-Value Array Query Parameters: Uses Hono's c.req.queries() to gracefully ingest array query parameters (e.g. ?tags=node&tags=bun or ?tags[]=edge), coercing elements and providing native arrays to action schemas.
  • Custom Content-Type Support: Respects action.http.customContentType for non-JSON responses (such as text/csv, image/svg+xml, or text/plain).
  • Idempotency Replay Indication: Emits the standard Idempotent-Replayed: true header when returning cached idempotent executions.
  • Built-in CORS & Preflight: Automatically handles CORS preflight OPTIONS and validates incoming Origin against config.security.allowedOrigins.
  • Pure Web-Standard Engine: Contains strictly zero node:* imports; 100% compatible with Cloudflare Workers isolates, AWS Lambda, Bun, and Node.js.

Installation

pnpm add @shukoi/api @shukoi/core hono @sinclair/typebox
# or
npm install @shukoi/api @shukoi/core hono @sinclair/typebox
# or
bun add @shukoi/api @shukoi/core hono @sinclair/typebox

Quickstart

import { createRestRouter } from '@shukoi/api';
import { createDefaultConfig } from '@shukoi/core';
import { myAction } from './actions/myAction.js';

const config = createDefaultConfig({
  security: {
    allowedOrigins: ['https://app.example.com'],
  },
});

// Create Hono REST application exposing actions
export const app = createRestRouter([myAction], config);

// Serve OpenAPI 3.1 specification at /openapi.json
// Execute routes with Hono: app.request('/my-action', { method: 'POST', ... })

API Reference

createRestRouter(actions, config, options?)

Creates a configured Hono application mounting all actions where action.http is declared.

  • Automatically mounts /openapi.json.
  • Configures CORS middleware.
  • Configures universal RFC 9457 error handler and 404 route handler.
  • Supports multi-value array query parameters and custom content types.
  • Emits Idempotent-Replayed: true headers on cached idempotency hits.

readBoundedJsonStream(stream, maxBytes)

Reads a ReadableStream<Uint8Array> up to maxBytes without trusting the Content-Length header. Cancels the stream reader immediately upon threshold breach with HTTP 413 and parses UTF-8 JSON.

generateOpenApiSpec(actions, config)

Generates an OpenAPI 3.1.0 JSON-serializable specification document from an array of CompiledAction instances, including query parameters, security schemes, and server definitions.

coercePrimitiveParam(raw)

Coerces string-based query or path parameter values into primitives based on value appearance, while preserving strings with leading zeros (e.g. "01234").

extractHeaders(req)

Extracts and normalizes all incoming request headers into a lowercase string record.


Related Documentation & Architecture


License

MIT © Shukoi Contributors