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-gcp

v3.0.2

Published

Google Cloud Platform server sources for walkerOS (Cloud Functions)

Downloads

1,498

Readme

@walkeros/server-source-gcp

Google Cloud Platform server sources for walkerOS - lightweight, single-purpose runtime adapters for GCP services.

Installation

npm install @walkeros/server-source-gcp @google-cloud/functions-framework

Usage

import {
  sourceCloudFunction,
  type SourceCloudFunction,
} from '@walkeros/server-source-gcp';
import { startFlow } from '@walkeros/collector';
import { http } from '@google-cloud/functions-framework';

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

http('walkerHandler', elb);

Cloud Functions Source

The Cloud Functions source provides an HTTP handler that receives walker events and forwards them to the walkerOS collector.

Basic Usage

import {
  sourceCloudFunction,
  type SourceCloudFunction,
} from '@walkeros/server-source-gcp';
import { startFlow } from '@walkeros/collector';
import { http } from '@google-cloud/functions-framework';

// Handler singleton - reused across warm invocations
let handler: SourceCloudFunction.Push;

async function setup() {
  if (handler) return handler;

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

  handler = elb;
  return handler;
}

// Register with Cloud Functions framework
setup().then((h) => http('walkerHandler', h));

Bundler Integration

Use with minimal config:

{
  "sources": {
    "api": { "type": "cloudfunction", "cors": true }
  }
}

Bundler auto-generates deployable exports.

Configuration Options

interface Settings {
  cors?: boolean | CorsOptions; // Enable CORS (default: true)
  batch?: boolean; // Enable batch processing (default: true)
  maxBatchSize?: number; // Max events per batch (default: 100)
  timeout?: number; // Request timeout (default: 30000ms)
}

interface CorsOptions {
  origin?: string | string[]; // Allowed origins
  methods?: string[]; // Allowed methods
  headers?: string[]; // Allowed headers
  credentials?: boolean; // Allow credentials
  maxAge?: number; // Preflight cache time
}

Ingest Metadata

Extract request metadata and forward it to processors and destinations:

await startFlow({
  sources: {
    api: {
      code: sourceCloudFunction,
      config: {
        settings: { cors: true },
        ingest: {
          ip: 'ip',
          ua: 'headers.user-agent',
          origin: 'headers.origin',
        },
      },
    },
  },
});

Available ingest paths:

| Path | Description | | ----------- | --------------------------------- | | ip | Client IP address | | headers.* | HTTP headers (user-agent, origin) | | method | HTTP method | | hostname | Request hostname |

Request Format

Single Event:

{
  "event": "page view",
  "data": {
    "title": "Home Page",
    "path": "/"
  },
  "context": {
    "stage": ["prod", 1]
  }
}

Batch Events:

{
  "events": [
    {
      "event": "page view",
      "data": { "title": "Page 1" }
    },
    {
      "event": "button click",
      "data": { "id": "btn1" }
    }
  ]
}

Response Format

Success:

{
  "success": true,
  "id": "event-id-123"
}

Batch Success:

{
  "success": true,
  "processed": 2,
  "errors": []
}

Error:

{
  "success": false,
  "error": "Invalid event format"
}

Deployment

The source is designed to work with the walkerOS deployment system:

{
  "providers": [
    {
      "name": "api-endpoint",
      "type": "gcp-functions",
      "artifact": {
        "source": "bundler",
        "bundle": "api-collector"
      },
      "settings": {
        "functionName": "walker-collector",
        "runtime": "nodejs18",
        "memory": 256
      }
    }
  ]
}

Testing

The source uses environment injection for testability:

import { sourceCloudFunction } from '@walkeros/server-source-gcp';

const mockElb = jest.fn().mockResolvedValue({
  ok: true,
  event: { id: 'test-id' },
});

const source = await sourceCloudFunction(
  { settings: { cors: false } },
  { elb: mockElb },
);

// Test the handler
const mockReq = { method: 'POST', body: { event: 'test' } };
const mockRes = { status: jest.fn().mockReturnThis(), json: jest.fn() };

await source.push(mockReq, mockRes);

expect(mockElb).toHaveBeenCalledWith('test', {});
expect(mockRes.status).toHaveBeenCalledWith(200);

Architecture

This source follows the walkerOS patterns:

  • Stateless: No collector references, communicates via elb function
  • Environment Injection: All dependencies provided through environment
  • Lean Implementation: Minimal required fields, focused on HTTP handling
  • Standard Interface: The push function IS the Cloud Function handler
  • Plug-and-Play: Direct assignment: http('handler', source.push)

The source's push function accepts HTTP requests, transforms them into walker events, and forwards them to the collector for processing by destinations.