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 🙏

© 2025 – Pkg Stats / Ryan Hefner

wkrk

v0.0.6

Published

A lightweight framework for CloudFlare Workers

Readme

👩‍🚒 Features

  • Simple routing system.
  • Handy helpers that return native Request and Response objects for maximum compatibility.
  • TypeScript support.
  • No build tools.

Installation

npm: npm i wkrk

yarn: yarn add wkrk

Getting Started

To get started, simply export a call to the wkrk function with your routes. Let's start with a route that responds to the /users path:

// index.js
import { wkrk } from "wkrk";
import users from "./api/users";

const routes = { "/users": users };

export default wkrk(routes);

Then define a simple handler for GET requests:

// api/users.js
export default {
  get({ req, res }) {
    return res.status(200).json({ name: "Giovanni" });
  },
};

You can also define everything in a single file:

import { wkrk } from "wkrk";

const routes = {
  "/users": {
    get({ req, res }) {
      return res.status(200).json({ name: "Giovanni" });
    },
  },
};

export default wkrk(routes);

Although working on a single file works, we highly recommend to separate your routes into multiple files and join them in your main index file:

import { wkrk } from "wkrk";
import users from "./api/users";
import posts from "./api/posts";

const routes = {
  "/users": users,
  "/posts": posts,
};

export default wkrk(routes);

Handling HTTP Methods

You can add the following functions to your routes:

  • get: Handles GET requests.
  • post: Handles POST requests.
  • put: Handles PUT requests.
  • delete: Handles DELETE requests.
  • handler: Handles all requests that aren't defined by any function above.

You can combine handler with the other functions. An example of this is shown below:

export default {
  get({ req, res }) {
    return res.status(200).json({ name: "Giovanni" });
  },
  handler({ req, res }) {
    return res.status(200).send("I match everything except GET requests.");
  },
};

Extensions

Every handler has two parameters: req and res. res provides handy methods that returns a native Request object that your Workers already understand.

res.json({ name: "Giovanni" });
res.status(200).json({ name: "Giovanni" });
res.status(200).send("I return some plain text");

// Set the content type to text/html and return some data
res.set("Content-Type", "text/html");
res.send("<p>Hello World!</p>");

How it Works

wkrk does not do any magic, it's just syntactic sugar for your workers ✨

As an example, the following:

import { wkrk } from "wkrk";

const routes = {
  "/users": {
    get({ req, res }) {
      return res.status(200).json({ name: "Giovanni" });
    },
  },
};

export default wkrk(routes);

Is equivalent to:

export default {
  async fetch(request: Request): Promise<Response> {
    if (request.method === "GET") {
      const json = JSON.stringify({ name: "Giovanni" });
      return new Response(json);
    }

    return new Response("I don't know how to handle this request", {
      status: 500,
    });
  },
};

File System Routing

API routes are great and are used by frameworks like Next.js and NuxtJS. However, read the file system it's not possible. An alternative to this is to provide a compiler that pulls this data and generates the configuration for your router. However, I choosed to keep it simple for now and avoid overcomplicate things in the very beginning.