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

@autumnsgrove/infra

v0.1.1

Published

Infrastructure abstraction layer for Grove — the roots run deep, the tree stands anywhere

Downloads

39

Readme

Infra SDK

The roots run deep. The tree stands anywhere.

Infrastructure abstraction layer that wraps each primitive (database, storage, key-value, scheduling, service calls, configuration) in a clean TypeScript interface. Today, Cloudflare adapters power everything. Tomorrow, the same application code could run on any cloud. The interface stays the same. Only the roots change.

Installation

# Direct dependency
pnpm add @autumnsgrove/infra

# Or via Lattice monorepo (recommended for Grove apps)
import type { GroveContext } from "@autumnsgrove/lattice/infra";
import { createCloudflareContext } from "@autumnsgrove/lattice/infra/cloudflare";
import { createMockContext } from "@autumnsgrove/lattice/infra/testing";

Quick Start

import { createCloudflareContext } from "@autumnsgrove/infra/cloudflare";

export default {
	async fetch(request: Request, env: Env): Promise<Response> {
		const ctx = createCloudflareContext({
			db: env.DB,
			storage: env.STORAGE,
			kv: env.CACHE_KV,
			services: { auth: env.AUTH, amber: env.AMBER },
			env,
		});
		return handleRequest(request, ctx);
	},
};

Application code only sees GroveContext — never Cloudflare-specific types:

async function handleRequest(request: Request, ctx: GroveContext): Promise<Response> {
	const posts = await ctx.db.execute("SELECT * FROM posts WHERE tenant_id = ?", [tenantId]);
	const avatar = await ctx.storage.get(`${tenantId}/avatar.webp`);
	const cached = await ctx.kv.get(`cache:${tenantId}:settings`);
	// ...
}

Interfaces

| Interface | ctx.* | CF Adapter | What It Wraps | | ----------------- | --------------- | ---------------------- | ------------------- | | GroveDatabase | ctx.db | CloudflareDatabase | D1 (SQLite) | | GroveStorage | ctx.storage | CloudflareStorage | R2 (S3-compatible) | | GroveKV | ctx.kv | CloudflareKV | Workers KV | | GroveServiceBus | ctx.services | CloudflareServiceBus | Service Bindings | | GroveScheduler | ctx.scheduler | CloudflareScheduler | Cron Triggers | | GroveConfig | ctx.config | CloudflareConfig | Worker env bindings |

Export Paths

| Path | Contents | Use In | | -------------------------------- | --------------------------------------- | --------------------------------- | | @autumnsgrove/infra | Interfaces + types + error catalog | Application code, type signatures | | @autumnsgrove/infra/cloudflare | CF adapters + createCloudflareContext | Worker entry points only | | @autumnsgrove/infra/testing | In-memory mocks + createMockContext | Test files |

Via Lattice re-exports: @autumnsgrove/lattice/infra, @autumnsgrove/lattice/infra/cloudflare, @autumnsgrove/lattice/infra/testing.

Testing

import { describe, it, expect, beforeEach } from "vitest";
import { createMockContext, type MockGroveContext } from "@autumnsgrove/infra/testing";

describe("PostService", () => {
	let ctx: MockGroveContext;

	beforeEach(() => {
		ctx = createMockContext();
	});

	it("should fetch posts from database", async () => {
		ctx.db.whenQuery("SELECT", [{ id: 1, title: "Hello" }]);
		const result = await ctx.db.execute("SELECT * FROM posts");
		expect(result.results).toHaveLength(1);
	});

	it("should upload to storage", async () => {
		await ctx.storage.put("tenant/file.txt", "hello");
		expect(ctx.storage.has("tenant/file.txt")).toBe(true);
	});

	it("should read config", () => {
		ctx.config.set("STRIPE_KEY", "sk_test_123");
		expect(ctx.config.require("STRIPE_KEY")).toBe("sk_test_123");
	});
});

Error Codes

The SDK uses SRV-XXX Signpost error codes. All errors flow through logGroveError with warm user-facing messages and detailed admin messages.

| Range | Category | Examples | | --------------------- | ------------------------------- | ---------------------------------------------------- | | SRV-001SRV-019 | Infrastructure & initialization | Missing bindings, context init failure | | SRV-020SRV-039 | Auth & sessions | Reserved for future use | | SRV-040SRV-059 | Business logic / operations | Query failures, upload errors, service call failures | | SRV-060SRV-079 | Rate limiting | Reserved for Threshold integration | | SRV-080SRV-099 | Internal / catch-all | Adapter errors, serialization, timeouts |

See docs/specs/server-sdk-spec.md for the full catalog.

Architecture

The SDK follows the Ports and Adapters pattern (hexagonal architecture):

  • Ports = the TypeScript interfaces (GroveDatabase, GroveStorage, etc.)
  • Adapters = the platform-specific implementations (CloudflareDatabase, etc.)
  • Context = the wiring point that connects ports to adapters (createCloudflareContext)

Application code depends only on ports. Adapters are injected at startup. To support a new platform, you write new adapters — the application code doesn't change.

  Application Code  →  GroveContext (interfaces)
                              │
                    ┌─────────┼─────────┐
                    ▼         ▼         ▼
              Cloudflare   Node.js   Testing
              adapters    adapters    mocks

Related

  • Spec: docs/specs/server-sdk-spec.md
  • Agent guide: AgentUsage/server_sdk_guide.md
  • Error handling: AgentUsage/error_handling.md
  • Loom SDK: packages/engine/src/lib/loom/ (Durable Object coordination, integrates with Infra SDK)