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

@zapiu/server

v1.0.1

Published

Backend contract 1 for Node.js 22+ and Fastify 5.

Downloads

355

Readme

@zapiu/server

Backend contract 1 for Node.js 22+ and Fastify 5.

import { defineBackend, getZapiuContext } from "@zapiu/server";

export default defineBackend({
  register(app) {
    app.get("/api/notes", async (request) => {
      return getZapiuContext(request).services.database.list("notes");
    });
  },
});

The configured compiled entry must default-export an object with runtimeContractVersion: 1 and register(app, context). Wrappers and re-exports are supported. Optional initialize(context) runs once before registration; cleanup() runs on close and failed initialization. The entry must not listen. The platform loads it through @zapiu/server/launcher in a separate application container. @zapiu/server/local provides a credential-free local runtime.

Request context and supported services

getZapiuContext(request) exposes tenantId, appId, environment, userId, requestId, and request-scoped services. Database supports list(table, query) and insert(table, values). Storage supports read(key) and write(key, bytes, contentType) for objects up to 1 MiB. Database reads and storage are scoped to the authenticated owner as well as app and environment. Protected owner fields cannot be supplied on insert.

@zapiu/server/broker obtains identity from the platform over HTTPS using an opaque, five-minute Code App session. The platform issues that session only after its normal authentication and Code Apps permission checks. Each broker operation verifies the session independently, including write permission. Production writes require production permission when the session is issued. Source capability declarations cannot grant access.

Built-in routes

  • GET /api/health: public runtime health.
  • GET /api/zapiu/context: public application context; validates a bearer session when present and reports authentication errors instead of silently downgrading.
  • GET /api/v1/me: authenticated current user, compatible with @zapiu/client.
  • GET /api/v1/resources/:table: owner-scoped list with limit/cursor.
  • POST /api/v1/resources/:table: schema-validated owner-scoped insert.

The current Code App adapter supports list/create operations. Page SDK record get/update and action APIs are separate contracts and are not supplied here. Reserve /api/ for backend routes. Initialization errors prevent startup. A separate platform transport serves the configured static frontend directory.

Platform setup and security

The control plane requires CODE_APP_BROKER_SECRET (at least 32 random bytes) and a private R2 source bucket for storage. The isolated launcher receives only nonsecret deployment context and the HTTPS broker origin. Signing keys, unrestricted database/storage credentials, and control-plane credentials must never enter an application container. Local runtime managed operations fail with an explicit connection error; they do not use production data.

SDK code is not a security or isolation boundary. The broker enforces scope when application code bypasses this package. Hosting must provide separate application/environment containers, restricted service identities, resource limits, and no shared host filesystem or privileged metadata credentials.