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

@kaibun/appwrite-fn-router

v0.3.3

Published

A router for Appwrite Functions

Readme

Appwrite Function Router

This library is a wrapper for Itty’s Router, tailored to the constraints of Appwrite’s FaaS implementation.

Usage

import type { AppwriteContext, AppwriteResponseObject, JSONObject } from "appwrite-fn-router"
import { handleRequest } from "appwrite-fn-router";
import { myRouteHandler } from "./routes";

// Optionally define a custom JSON response schema:
type MyJSONResponse = {
  status: 'success' | 'error';
  message: string;
  error?: string;
} & JSONObject;

// This async function is your regular Appwrite’s mandatory function handler:
export default async (context: AppwriteContext) => {
  // One may leverage Appwrite’s provided context properties if need be:
  // const { req, res, log, error } = context;

  // Those properties would be accessible from within the routes handlers thanks
  // to the JavaScript closure, but one may import handlers from a file, so
  // the best practice here is to  pass that context alongside your routes
  // (defined using Itty’s API): the context is made available to the route
  // handlers):
  return handleRequest(context, (router) => {
    // In a route handler, request is a native Request object, while req is the
    // Appwrite’s specific request flavor. You also get access to the rest of
    // Appwrite’s function’s context: res, log and error objects.
    router.get('/hello', (request, req, res, log, error) => {
      return res.json({
        status: 'success',
        message: 'Hello, world!',
      }) satisfies AppwriteResponseObject<MyJSONResponse>;
    });

    router.post('/data', async (request, req, res, log, error) => {
      const data = await req.bodyJson;
      return res.json({
        received: data,
      });
    });

    // Despite being defined outside the closure, myRouteHandler still has
    // access to the function’s context, through it’s params. How handy!
    router.get("/mystery", myRouteHandler);
  });

Local Development

For instructions on how to set up a local development environment with hot-reloading, please see the Contributing Guide.

Overview

Mono-repo (TypeScript/Node.js): The main project is an npm library that provides a router for Appwrite Functions, built as a wrapper around Itty Router.

Organization: Multiple sub-projects, including core src code, documentation (Docusaurus), Appwrite test functions, OpenAPI schema, types, Cypress E2E tests, and more.

Folder Structure

  • src: Main source code (TypeScript, React components, utilities)
  • doc: Docusaurus documentation (custom theme, code examples, markdown docs)
  • functions: Appwrite test functions (npm workspace, TypeScript code)
  • openapi: OpenAPI schema and generation scripts
  • cypress: Cypress end-to-end tests
  • types: TypeScript type definitions