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

@walkeros/server-source-fetch

v0.6.0

Published

Web Standard Fetch API source for walkerOS (Cloudflare Workers, Vercel Edge, Deno, Bun)

Readme

@walkeros/server-source-fetch

Web Standard Fetch API source for walkerOS - Deploy to any modern edge/serverless platform

What This Source Does

Accepts walkerOS events via HTTP (Fetch API) Forwards events to collector for processing Returns HTTP responses with CORS support

This is an HTTP transport layer - it accepts events in walkerOS format and forwards them to the collector. Not a transformation source.

Features

  • Web Standard Fetch API - Native (Request) => Response signature
  • Platform Agnostic - Cloudflare Workers, Vercel Edge, Deno, Bun, Node.js 18+
  • Event Validation - Zod schema validation with detailed error messages
  • Batch Processing - Handle multiple events in single request
  • CORS Support - Configurable cross-origin resource sharing
  • Pixel Tracking - 1x1 transparent GIF for GET requests
  • Request Limits - Configurable size and batch limits
  • Health Checks - Built-in /health endpoint

Installation

npm install @walkeros/server-source-fetch @walkeros/collector @walkeros/core

Quick Start

import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
import { startFlow } from '@walkeros/collector';

const { elb } = await startFlow<SourceFetch.Push>({
  sources: { api: { code: sourceFetch } },
});

export default { fetch: elb };

Platform Deployment

Cloudflare Workers

import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
import { startFlow } from '@walkeros/collector';

const { elb } = await startFlow<SourceFetch.Push>({
  sources: {
    api: {
      code: sourceFetch,
      config: { settings: { cors: true } },
    },
  },
  destinations: {
    // Your destinations
  },
});

export default { fetch: elb };

Deploy: wrangler deploy

Vercel Edge Functions

// api/collect.ts
export const config = { runtime: 'edge' };

import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
import { startFlow } from '@walkeros/collector';

const { elb } = await startFlow<SourceFetch.Push>({
  sources: { api: { code: sourceFetch } },
});

export default elb;

Deno Deploy

import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
import { startFlow } from '@walkeros/collector';

const { elb } = await startFlow<SourceFetch.Push>({
  sources: { api: { code: sourceFetch } },
});

Deno.serve(elb);

Bun

import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
import { startFlow } from '@walkeros/collector';

const { elb } = await startFlow<SourceFetch.Push>({
  sources: { api: { code: sourceFetch } },
});

Bun.serve({ fetch: elb, port: 3000 });

Usage Examples

Single Event (POST)

fetch('https://your-endpoint.com/collect', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    name: 'page view',
    data: { title: 'Home', path: '/' },
    user: { id: 'user-123' },
    globals: { language: 'en' },
  }),
});

Batch Events (POST)

fetch('https://your-endpoint.com/collect', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    batch: [
      { name: 'page view', data: { title: 'Home' } },
      { name: 'button click', data: { id: 'cta' } },
      { name: 'form submit', data: { formId: 'contact' } },
    ],
  }),
});

Pixel Tracking (GET)

<img
  src="https://your-endpoint.com/collect?event=page%20view&data[title]=Home&user[id]=user123"
  width="1"
  height="1"
/>

Health Check

curl https://your-endpoint.com/health
# {"status":"ok","timestamp":1234567890,"source":"fetch"}

Configuration

interface Settings {
  path: string; // Collection path (default: '/collect')
  cors: boolean | CorsOptions; // CORS config (default: true)
  healthPath: string; // Health check path (default: '/health')
  maxRequestSize: number; // Max bytes (default: 102400 = 100KB)
  maxBatchSize: number; // Max events per batch (default: 100)
}

interface CorsOptions {
  origin?: string | string[] | '*';
  methods?: string[];
  headers?: string[];
  credentials?: boolean;
  maxAge?: number;
}

Error Responses

Validation Error

{
  "success": false,
  "error": "Event validation failed",
  "validationErrors": [
    { "path": "name", "message": "Event name is required" },
    { "path": "nested.0.entity", "message": "Required" }
  ]
}

Batch Partial Failure (207 Multi-Status)

{
  "success": false,
  "processed": 2,
  "failed": 1,
  "errors": [
    { "index": 1, "error": "Validation failed: Event name is required" }
  ]
}

Input Format

Accepts standard walkerOS events. See @walkeros/core Event documentation.

Required field:

  • name (string) - Event name in "entity action" format (e.g., "page view")

Optional fields:

  • data - Event-specific properties
  • user - User identification
  • context - Ordered context properties
  • globals - Global properties
  • custom - Custom properties
  • nested - Nested entities
  • consent - Consent flags

Testing

npm test        # Run tests
npm run dev     # Watch mode
npm run lint    # Type check + lint
npm run build   # Build package

Development

Follows walkerOS XP principles:

  • DRY - Uses @walkeros/core utilities
  • KISS - Minimal HTTP wrapper
  • TDD - Example-driven tests
  • No any - Strict TypeScript

See AGENT.md for walkerOS development guide.

Related

License

MIT