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

v0.6.0

Published

AWS server sources for walkerOS (Lambda, API Gateway, Function URLs)

Readme

@walkeros/server-source-aws

AWS server sources for walkerOS - lightweight, single-purpose runtime adapters for AWS services.

Installation

npm install @walkeros/server-source-aws @types/aws-lambda

Usage

import { sourceLambda, type SourceLambda } from '@walkeros/server-source-aws';
import { startFlow } from '@walkeros/collector';

const { elb } = await startFlow<SourceLambda.Push>({
  sources: { lambda: { code: sourceLambda } },
});

export const handler = elb;

Lambda Source

The Lambda source provides an HTTP handler that receives walker events and forwards them to the walkerOS collector. Works with API Gateway v1 (REST API), v2 (HTTP API), and Lambda Function URLs.

Basic Usage

import { sourceLambda, type SourceLambda } from '@walkeros/server-source-aws';
import { startFlow } from '@walkeros/collector';

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

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

  const { elb } = await startFlow<SourceLambda.Push>({
    sources: {
      lambda: {
        code: sourceLambda,
        config: {
          settings: {
            cors: true,
            healthPath: '/health',
          },
        },
      },
    },
    destinations: {
      // Your destinations
    },
  });

  handler = elb;
  return handler;
}

export const main: SourceLambda.Push = async (event, context) => {
  const h = await setup();
  return h(event, context);
};

// Export for Lambda runtime
export { main as handler };

Deployment

Lambda Function URL (Simplest)

// No API Gateway needed
import * as lambda from 'aws-cdk-lib/aws-lambda';

const fn = new lambda.Function(this, 'Walker', {
  runtime: lambda.Runtime.NODEJS_20_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('./dist'),
});

fn.addFunctionUrl({
  authType: lambda.FunctionUrlAuthType.NONE,
  cors: {
    allowedOrigins: ['*'],
    allowedMethods: [lambda.HttpMethod.GET, lambda.HttpMethod.POST],
  },
});

API Gateway HTTP API (v2) - Recommended

# serverless.yml
service: walkeros-collector

provider:
  name: aws
  runtime: nodejs20.x
  memorySize: 256
  timeout: 30

functions:
  collector:
    handler: dist/index.handler
    events:
      - httpApi:
          path: /collect
          method: post
      - httpApi:
          path: /collect
          method: get
      - httpApi:
          path: /health
          method: get

API Gateway REST API (v1)

# template.yaml (AWS SAM)
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Resources:
  WalkerFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: ./dist
      Handler: index.handler
      Runtime: nodejs20.x
      Architectures: [arm64]
      Events:
        CollectPost:
          Type: Api
          Properties:
            Path: /collect
            Method: POST
        CollectGet:
          Type: Api
          Properties:
            Path: /collect
            Method: GET
        Health:
          Type: Api
          Properties:
            Path: /health
            Method: GET

Configuration Options

interface Settings {
  cors?: boolean | CorsOptions; // Enable CORS (default: true)
  timeout?: number; // Request timeout (default: 30000ms, max: 900000ms)
  enablePixelTracking?: boolean; // Enable GET tracking (default: true)
  healthPath?: string; // Health check path (default: '/health')
}

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

Request Format

POST - Single Event:

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

GET - Pixel Tracking:

GET /collect?event=page%20view&data[title]=Home&data[path]=/

Response Format

Success:

{
  "success": true,
  "id": "event-id-123",
  "requestId": "aws-request-id"
}

Error:

{
  "success": false,
  "error": "Invalid request format",
  "requestId": "aws-request-id"
}

Health Check:

{
  "status": "ok",
  "timestamp": 1733328000000,
  "source": "lambda",
  "requestId": "aws-request-id"
}

Supported Platforms

  • ✅ AWS API Gateway REST API (v1)
  • ✅ AWS API Gateway HTTP API (v2)
  • ✅ Lambda Function URLs
  • ✅ Direct Lambda invocation

Features

  • Auto-detection: Automatically detects API Gateway version
  • CORS: Configurable CORS with defaults
  • Pixel Tracking: Optional GET requests with 1x1 GIF response
  • Base64 Decoding: Handles base64-encoded request bodies
  • Health Checks: Built-in health check endpoint
  • Request IDs: AWS request ID in all responses and logs
  • Logging: Integrated with walkerOS logger
  • Type-Safe: Full TypeScript support

Production Considerations

Cold Starts

Use handler singleton pattern (shown in Basic Usage) to reuse source instance across warm invocations.

Logging

The source integrates with the walkerOS logger from env.logger. Configure CloudWatch Logs:

import { createLogger } from '@walkeros/core';

const logger = createLogger({
  level: 'info',
  // CloudWatch-friendly JSON output
  format: (level, message, meta) =>
    JSON.stringify({ level, message, ...meta, timestamp: Date.now() }),
});

Error Handling

All errors include request IDs for tracing. Configure CloudWatch Insights queries:

fields @timestamp, level, message, requestId, error
| filter level = "error"
| sort @timestamp desc

Monitoring

Key metrics to track:

  • Lambda Duration (p50, p99)
  • Lambda Errors
  • Lambda Throttles
  • API Gateway 4xx/5xx responses

Security

  • Use API Gateway with API keys or AWS IAM for authentication
  • Enable AWS WAF for DDoS protection
  • Set Lambda reserved concurrency to prevent runaway costs
  • Validate CORS origins in production (don't use cors: true)

Examples

See examples directory for:

  • SAM deployment
  • Serverless Framework deployment
  • CDK deployment
  • Local testing with SAM CLI

License

MIT

Support