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

durable-object-fs

v0.1.1

Published

SQLite-backed filesystem Durable Object for Cloudflare Workers

Readme

durable-object-fs

A Durable Object that implements a filesystem interface using SQLite storage. Can be mounted via worker-fs-mount to provide persistent filesystem storage in Cloudflare Workers.

Installation

npm install durable-object-fs worker-fs-mount

Usage

1. Configure wrangler.toml

[[migrations]]
tag = "v1"
new_sqlite_classes = ["DurableObjectFilesystem"]

[alias]
"node:fs/promises" = "worker-fs-mount/fs"

Note: No [[durable_objects.bindings]] section is needed - use ctx.exports to access the Durable Object namespace directly.

2. Generate types with wrangler

wrangler types

This generates a worker-configuration.d.ts file with typed exports for your Durable Objects.

3. Export the Durable Object and use it

import { DurableObjectFilesystem } from 'durable-object-fs';
import { mount, withMounts } from 'worker-fs-mount';
import { WorkerEntrypoint } from 'cloudflare:workers';
import fs from 'node:fs/promises';

// Export the Durable Object class
export { DurableObjectFilesystem };

export default class extends WorkerEntrypoint<Env> {
  async fetch(request: Request) {
    // Durable Objects require request scope - use withMounts
    return withMounts(async () => {
      // Get a Durable Object instance via ctx.exports (fully typed!)
      const id = this.ctx.exports.DurableObjectFilesystem.idFromName('shared');
      const stub = this.ctx.exports.DurableObjectFilesystem.get(id);

      // Mount the filesystem
      mount('/data', stub);

      // Use standard fs operations
      await fs.writeFile('/data/hello.txt', 'Hello, World!');
      const content = await fs.readFile('/data/hello.txt', 'utf8');

      // Create directories
      await fs.mkdir('/data/projects/my-app', { recursive: true });

      // List directory contents
      const files = await fs.readdir('/data/projects');

      return new Response(content);
    });
  }
}

Features

  • Full WorkerFilesystem interface implementation
  • Persistent storage via SQLite (survives restarts)
  • Support for files, directories, and symlinks
  • Streaming read/write support
  • Atomic operations within a single request

API

The DurableObjectFilesystem class implements the full WorkerFilesystem interface. See the worker-fs-mount README for the complete API reference.

Storage

Data is stored in the Durable Object's SQLite database with the following schema:

CREATE TABLE entries (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  path TEXT NOT NULL UNIQUE,
  parent_path TEXT NOT NULL,
  name TEXT NOT NULL,
  type TEXT NOT NULL CHECK (type IN ('file', 'directory', 'symlink')),
  size INTEGER NOT NULL DEFAULT 0,
  content BLOB,
  symlink_target TEXT,
  created_at INTEGER NOT NULL,
  modified_at INTEGER NOT NULL
);

Limitations

  • File size: SQLite BLOBs can store files up to several GB, but large files (>100MB) may impact performance
  • Streaming: Streams buffer content in memory before writing to SQLite
  • Concurrency: Durable Objects are single-threaded, so concurrent access from multiple workers serializes automatically

License

MIT