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

@yingyeothon/s3-cache-bridge-client

v2.2.0

Published

HTTP client for the s3-cache-bridge server: get/put/delete, append, lock/unlock, and cache sync helpers.

Readme

@yingyeothon/s3-cache-bridge-client

HTTP client for the s3-cache-bridge server: read, write, delete, and append cached objects, patch JSON documents in place, control per-key locks, and trigger cache sync or invalidation — all over plain HTTP with optional basic auth. Built on the global fetch with zero runtime dependencies.

The bridge answers from its cache when it can, and reaches S3 when it cannot.

sequenceDiagram
  participant C as createS3cbClient
  participant B as the bridge server
  participant S as S3
  C->>B: read a key
  alt cached
    B-->>C: the value
  else not cached
    B->>S: GET
    S-->>B: the object
    B-->>C: the value
  end

Install

npm install @yingyeothon/s3-cache-bridge-client

Usage

ESM:

import { createS3cbClient } from "@yingyeothon/s3-cache-bridge-client";

const cb = createS3cbClient({
  apiUrl: "https://cache.example.com/",
  apiId: "my-id",
  apiPassword: "my-password",
});

await cb.put("greeting", "WORLD");
const text = await cb.get("greeting"); // "WORLD"
await cb.append("greeting", "!");
const exists = await cb.exists("greeting"); // true

// JSON modification protocol.
const fetched = await cb.patch<{ a: { b: { c: number } } }>(
  "doc",
  { operation: "append", path: "a.b", value: { c: 10 } },
  { fetch: true },
);

// Manual locking.
await cb.lock("greeting");
await cb.put("greeting", "LOCKED WRITE", { noLock: true });
await cb.unlock("greeting");

// Binary and file transfer.
const bytes = await cb.getBuffer("image");
await cb.download("image", "/tmp/image.png");

await cb.del("greeting");

CJS:

const { createS3cbClient } = require("@yingyeothon/s3-cache-bridge-client");
const cb = createS3cbClient({ apiUrl: "http://localhost:3000/" });
cb.get("key").then(console.log);

Public API

  • createS3cbClient(options) — factory that binds every method below to one server environment
  • S3cbClientOptions{ apiUrl, apiId?, apiPassword? }; credentials become a Basic Authorization header (type)
  • S3cbClient — the object returned by createS3cbClient (type)
  • s3cbClientOptionsFromEnv() — builds S3cbClientOptions from the S3CB_URL, S3CB_ID, and S3CB_PASSWORD environment variables; throws if S3CB_URL is unset. Calling it is the caller's choice — the library itself never reads process.env
  • JSONModificationRequestappend / modify / remove / fetch operations for patch (type)
  • LockOptions{ noLock?: boolean } (type)
  • SyncOptions{ sync?: boolean } (type)
  • FetchOptions{ fetch?: boolean } (type)

Client methods:

  • get(key, options?) — GET the object as a UTF-8 string
  • put(key, body, options?) — PUT a string, Buffer, or Uint8Array
  • del(key, options?) — DELETE the object
  • append(key, body, options?) — PUT with append=1 to append to the object
  • sync(key) — POST with sync=1 to flush the key to S3
  • invalidate(key) — DELETE with cache=1 to drop the cached copy
  • lock(key) / unlock(key) — POST with lock=acquire / lock=release
  • patch<T>(key, modRequest, options?) — PATCH a JSON document; resolves the fetched value when fetch is on (defaults to on for the fetch operation), otherwise null
  • getBuffer(key, options?) — GET the object as a Buffer
  • download(key, downloadPath, options?) — stream the object into a local file, resolving the path
  • exists(key, options?) — HEAD the object; false on 404, throws on other errors

Every method rejects with an Error whose message is "<status> <statusText>" (for example "404 Not Found") when the server does not answer 200.

Migrating from the legacy package

  • The default export is gone and the factory was renamed: S3cbcreateS3cbClient (named export, import { createS3cbClient } from ...), and the S3cbEnv type → S3cbClientOptions. Every method is unchanged.
  • The package now ships dual ESM/CJS with types; deep imports (.../lib/...) are no longer supported — import everything from the package root.
  • Implemented on the global fetch (Node >= 20) instead of node-fetch/https; get-stream is no longer a dependency.
  • put no longer sets a manual Content-Length header; fetch derives the identical value from the buffered body automatically.
  • The DEBUG=1 console tracing of the legacy HTTP layer was removed.