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

fullstack-utils

v1.0.8

Published

Assorted collection of Hono middlewares, Preact hooks and various other components and functions that I saw myself using over and over...

Downloads

73

Readme

fullstack-utils

Assorted collection of Hono middlewares, Preact hooks and various other components and functions that I saw myself using over and over...

hono-cloudflare-content

Hono middleware for serving static content. Use it like this:

import {serveStatic} from "fullstack-utils/hono-cloudflare-content";
// ...assume app is a Hono instance.
app.use("*",serveStatic())

The reason why it exists is that it handles ETags differently than Hono's built in middleware.

hono-https-redirect

Hono middleware for redirecting all requests to HTTPS. Works like this:

import {httpsRedirect} from "fullstack-utils/hono-https-redirect";
// ...assume app is a Hono instance.
app.use("*",httpsRedirect({/* ...options... */}))

The httpsRedirect function accepts a configuration object with the following members:

  • ignore - Array of hostnames to ignore and not perform redirect. Default ["localhost"].

hono-quick-rpc

Hono middleware for creating an RPC endpoint. The enpoint is for the most part JSON-RPC compliant, but the main focus is not compliance but convenience in creating APIs for internal client-server communication in projects. Works like this:

import {quickRpc} from "fullstack-utils/hono-quick-rpc";

class Api {
    constructor(context) {
        // context is Hono request context
    }

    function myfunc() {
        // ...
    }
}

// ...assume app is a Hono instance.
app.use("/myapi",quickRpc(Api))

Now a JSON-RPC endpoint will exist on /myapi. All methods exposed by the class will be made available as JSON-RPC methods. The positional parameters passed in the JSON-RPC call will be passed to the method, named parameters are not supported. An instance of the class will be constructed for each request, and the request context will be passed to the constructor.

use-quick-rpc

A React context and hook for calling JSON-RPC endpoints. In order to use it, you need to first provide a context on a higher level in your component tree:

import {QuickRpcProvider} from "fullstack-utils/use-quick-rpc";

function TopLevelComponent({children}) {
    return (
        <QuickRpcProvider url="/myapi" fetch={fetch}>
            {children}
        </QuickRpcProvider>
    );
}

Then, you can make calls to the api in further down in your child components:

import {useQuickRpc} from "fullstack-utils/use-quick-rpc";

function ChildComponent() {
    let api=useQuickRpc();
    let result=await api.myfunc();
    // ...
}

fetch-ex

A wrapper for the fetch call.

use-feather

A spring based animation tool.

import {useFeather} from "fullstack-utils/use-feather";

function MyComponent() {
    let ref=useRef();
    let feather=useFeather(v=>ref.current.style.opacity=`${v}%`);

    feather.setTarget(100);

    return (
        <div ref={ref}>
            fading...
        </div>
    );
}