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

@boon4681/citron-ts

v0.0.2-13e

Published

Turn your @hono/zod-openapi or `openapi.json not confirm` to typescript fetch types.

Downloads

257

Readme

Citron-ts

Turn your @hono/zod-openapi or openapi.json not confirm to typescript fetch types.

import { $Types, Citron } from "./citron"
const k = fetch

export const GetPet = Citron("/api/pet/{id}").get(
    (path, fetch = k) => {
        return fetch(b`/api/pet/${path.id}`).then(res=>res.json())
    }
);

console.log(await GetPet({ id: 1 }))

Why?

i used to write code in my style to that why this happended.

Installation

# install with npm
npm install "@boon4681/citron-ts"
# install with yarn
yarn add "@boon4681/citron-ts"

Usage

  1. Setup config in citron.config.ts
import { defineConfig } from "./src";

export default defineConfig({
    schema: {
        url: 'http://localhost:3000/openapi.json',
        cookie: process.env['OPENAPI-COOKIE']
    },
    out:'./src'
})
  1. Generate the schema from config:
citron pull
  1. Use your types :
import { $Types, Citron } from "./citron"
const k = fetch

export const GetPet = Citron("/api/pet/{id}").get(
    (path, fetch = k) => {
        return fetch(b`/api/pet/${path.id}`).then(res=>res.json())
    }
);

console.log(await GetPet({ id:1 }))

Experimental: builder adapter

An opt-in client style that removes the per-endpoint boilerplate. Instead of writing a resolver for every route, you call a typed builder where each setter (.path()/.query()/.body()) is enforced by the type, and you fire the request with .execute().

Enable it in citron.config.ts:

export default defineConfig({
    schema: { url: 'http://localhost:3000/openapi.json' },
    out: './src',
    experimental: { adapter: 'builder' }
})

Generate the schema from config:

citron pull
import { createApi } from "./citron"

const api = createApi({
    baseUrl: "https://api.example.com",
    fetch: myFetch,                 // optional, defaults to global fetch
    init: { headers: { authorization: "Bearer ..." } }  // optional, merged into every request
})

// path param is required -> set it, then .execute()
const res = await api["/api/pet/{id}"].get().path({ id: 1 }).execute()
const pet = await res.json()

// no params / all-optional query
const all = await api["/api/pet"].get().execute()

// required body
await api["/api/pet"].post().body({ name: "rex" }).execute()

.execute() is the only way to send a request and returns Promise<Response>. Because it is gated on completion, forgetting a required slot fails to typecheck at the call site:

await api["/api/pet/{id}"].get().execute()   // ERROR: Property 'execute' does not exist (path missing)

The builder itself is not a promise — await-ing a chain without .execute() does not send anything.

baseUrl defaults to the OpenAPI servers[0].url, so createApi() with no arguments works when the document declares a server; pass baseUrl to override.

Contributing

Ideas and contributions to the project are welcome.