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

@firela/runtime-adapters

v0.1.1

Published

Platform-agnostic runtime adapters for Cloudflare Workers, Node.js, and edge runtimes

Readme

@firela/runtime-adapters

Platform-agnostic runtime adapters for Cloudflare Workers, Node.js, and edge runtimes.

Overview

This package provides a unified abstraction layer for runtime-specific capabilities, allowing your code to run seamlessly across different JavaScript environments:

  • Cloudflare Workers - KV storage, Web Crypto API
  • Node.js - File-based storage, Node crypto module
  • Edge runtimes - Any environment implementing the adapter interfaces

Installation

npm install @firela/runtime-adapters
# or
pnpm add @firela/runtime-adapters

Quick Start

Cloudflare Workers

import { createCloudflareAdapter } from '@firela/runtime-adapters/cloudflare'

export default {
  async fetch(request, env, ctx) {
    const adapter = createCloudflareAdapter(env)

    // Use KV store
    await adapter.kv.set('session:abc', { userId: 'user1' }, { ttl: 3600000 })

    // Use crypto
    const signature = await adapter.crypto.hmacSha256('payload', 'secret')

    // Log messages
    adapter.logger.info('Request processed')

    return new Response('OK')
  }
}

Node.js

import { createNodeAdapter } from '@firela/runtime-adapters/node'

const adapter = createNodeAdapter()

// Use in-memory KV store (useful for development/testing)
await adapter.kv.set('key', 'value')

// Use Node.js crypto
const bytes = adapter.crypto.randomBytes(16)

// Console logging
adapter.logger.info('Application started')

API Reference

Types

interface KVStore {
  get<T = unknown>(key: string): Promise<T | null>
  set<T>(key: string, value: T, options?: { ttl?: number }): Promise<void>
  delete(key: string): Promise<boolean>
}

interface CryptoAdapter {
  hmacSha256(data: string, secret: string): Promise<string>
  randomBytes(length: number): Uint8Array
}

interface Logger {
  debug(message: string, ...args: unknown[]): void
  info(message: string, ...args: unknown[]): void
  warn(message: string, ...args: unknown[]): void
  error(message: string, ...args: unknown[]): void
}

interface RuntimeAdapter {
  kv: KVStore
  crypto: CryptoAdapter
  logger: Logger
  platform: string
}

Cloudflare Adapter

import { createCloudflareAdapter } from '@firela/runtime-adapters/cloudflare'

const adapter = createCloudflareAdapter(env, 'KV') // 'KV' is the default namespace

Features:

  • CloudflareKVStore - Wraps KVNamespace for key-value storage
  • CloudflareCryptoAdapter - Uses Web Crypto API
  • ConsoleLogger - Console-based logging

Node.js Adapter

import { createNodeAdapter } from '@firela/runtime-adapters/node'

const adapter = createNodeAdapter()

Features:

  • MemoryKVStore - In-memory key-value storage (useful for development)
  • NodeCryptoAdapter - Uses Node.js crypto module
  • ConsoleLogger - Console-based logging

Usage Examples

Rate Limiting with KV Storage

import { createCloudflareAdapter } from '@firela/runtime-adapters/cloudflare'

const adapter = createCloudflareAdapter(env)

async function checkRateLimit(key: string, limit: number, windowMs: number): Promise<boolean> {
  const count = await adapter.kv.get<number>(key) || 0

  if (count >= limit) {
    return false
  }

  await adapter.kv.set(key, count + 1, { ttl: windowMs })
  return true
}

HMAC Signature Verification

import { createCloudflareAdapter } from '@firela/runtime-adapters/cloudflare'

const adapter = createCloudflareAdapter(env)

async function verifySignature(payload: string, signature: string, secret: string): Promise<boolean> {
  const expected = await adapter.crypto.hmacSha256(payload, secret)
  return expected === signature
}

License

MIT