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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ajarc

v0.0.1

Published

🫙 An O(1) fetch client for OpenAPIs

Downloads

3

Readme

Ajar

Ajar is an O(1) fetch client for APIs that implement the OpenAPI specification. It consumes a generic interface generated by openapi-typescript-codegen and returns a fully typed, deeply nested object that maps to fetch calls.

const client = Ajar<paths>()

client.feeds.get()
client.user["500"].comments.post()
client.user["500"].posts["3"].get()

Because it is implemented almost entirely using TypeScript's extensive type system, Ajar is largely capable of 'dissolving' during code compilation. In your app's bundle, all that remains is a lightweight[^1] core library that does not grow over time.

Currently, Ajar only implements a small subset of the OpenAPI specification[^2], however it should be more than enough for almost every project.

[^1]: When the core JavaScript is complete I'll have concrete numbers, however I'm positive it will not exceed 1kb. In addition, an optimization push will be made before every release [^2]: Look: at the end of the day, Ajar was made to solve my problems. I hope it solves yours as well, but I can tell you right now that I've already spent enough time wrangling with typescript to last a lifetime (and I'm pretty young, for the record). I don't want to prematurely squander even more time solving edge cases people (or more likely, corporations) might encounter. I try to live my life in the now. I'm happy to accept PRs (and even issues I guess, though I might ask for a "donation") that help push Ajar closer to compliance, just know it's not a goal.

How it works

Ajar makes use of JavaScript proxies to create an infinitely nested object, and each entry exposes a number of methods. This roughly maps to:

type AjarObject = {
    [key: string]: AjarObject
    get: () => {}
    post: () => {}
    ...
}

This object is then artificially restricted to a set of known paths using the type system. This approach is advantageous because it means there is no runtime growth.

Project status

Ajar is not currently usable. Almost all typing work has been completed, however the actual client is still a stub.

  • [x] 🟦 Extract response from paths
  • [x] 🟦 Generate basic chain type from a path
  • [x] 🟦 Generate a complete chained type from the paths type
  • [x] 🟨 Basic proxy
  • [x] 🟦 Support parameters in the chained type
  • [ ] 🟨 Create basic fetch client inside the proxy callback
  • [ ] 🟦 Type response
  • [ ] ⭐ Regression tests

Credits

This project was heavily inspired by the hono client which pioneered our usage of proxies.


It all started with a message:

In the SolidJS discord, BTW ;)