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

@kelceyp/caw-server

v0.0.43

Published

CAW server - REST API, MCP server, WebSocket bridge, and core features

Readme

CAW Server

The CAW server provides REST API, MCP server, WebSocket bridge, and core content management features.

Overview

The server is the central component of CAW, providing:

  • REST API - HTTP endpoints for web client and CLI
  • MCP Server - HTTP MCP server for Claude Code integration
  • WebSocket Bridge - Real-time communication with browser extension tabs
  • Core - Business logic layer (services, stores, entities)
  • Static File Hosting - Serves the web client

Architecture

┌─────────────────────────────────────────┐
│         API Layer (REST/MCP)            │  HTTP routes, MCP tools
│  (api/, mcp/)                           │  Auth via Bearer tokens
└─────────────────────────────────────────┘
                  ↓
┌─────────────────────────────────────────┐
│            Server.js                    │  Express app setup
│  (main.js)                              │  Port management
└─────────────────────────────────────────┘
                  ↓
┌─────────────────────────────────────────┐
│             Core Facade                 │  Token resolution
│  (core/Core.js)                         │  Service caching
│                                         │  Flat API
└─────────────────────────────────────────┘
                  ↓
┌─────────────────────────────────────────┐
│            Services Layer               │  Orchestration
│  (core/services/)                       │  Business workflows
│                                         │  Multi-store coordination
└─────────────────────────────────────────┘
                  ↓
┌─────────────────────────────────────────┐
│             Stores Layer                │  Data access
│  (core/stores/)                         │  Identity Map caching
│                                         │  CRUD operations
└─────────────────────────────────────────┘
                  ↓
┌─────────────────────────────────────────┐
│            Database Layer               │  SQLite
│  (db/)                                  │  Kysely query builder
└─────────────────────────────────────────┘

Directory Structure

server/
├── src/
│   ├── main.js              # Entry point, server initialization
│   ├── Server.js            # Express app factory
│   ├── api/                 # REST API routes
│   │   ├── ProjectRoutes.js
│   │   ├── FolderRoutes.js
│   │   ├── DocumentRoutes.js
│   │   ├── TemplateRoutes.js
│   │   ├── FieldRoutes.js
│   │   ├── ExportRoutes.js
│   │   └── EventRoutes.js
│   ├── core/                # Business logic layer
│   │   ├── Core.js          # Facade - token resolution, service caching
│   │   ├── entities/        # Domain objects (read-only)
│   │   ├── services/        # Orchestration layer
│   │   └── stores/          # Data access + caching
│   ├── db/                  # Database layer
│   │   ├── Connection.js    # Database connection factory
│   │   ├── schema.js        # Table definitions
│   │   └── seed.js          # Initial data seeding
│   ├── mcp/                 # MCP server implementation
│   ├── wss/                 # WebSocket server
│   ├── static/              # Static files for web client
│   └── common/              # Shared utilities
└── test/                    # Test suites
    ├── unit/                # In-memory unit tests
    ├── integration/         # Real database integration tests
    └── component/           # Black-box HTTP tests via subprocess

Port Configuration

The server uses the CAW_PORT environment variable:

CAW_PORT=3131 caw-server   # Default: 3131

Building

# Build server only
bun run build

# Build client + server
bun run build:all

Output: dist/main.js (ES6 module for Node.js)

Running

# Development (uses source files)
bun run dev

# Production (uses built files)
node dist/main.js

Testing

# Run all tests
bun test

# Run specific test suite
bun test test/unit/
bun test test/integration/
bun test test/component/

Test types:

  • Unit - In-memory tests (entities, utilities)
  • Integration - Real database tests (stores, services)
  • Component - Black-box HTTP tests (API routes, MCP tools)

Tech Stack

  • Pure JavaScript - ES6 modules, factory functions only
  • Express - HTTP server framework
  • Kysely - SQL query builder (type-safe)
  • better-sqlite3 - SQLite driver
  • ws - WebSocket server
  • MCP SDK - Model Context Protocol implementation
  • Bun - Build tool (development and bundling)

Distribution

Published to npm as @kelceyp/caw-server:

# Global install
npm install -g @kelceyp/caw-server

# Run
caw-server

Key Features

Token-Based Authentication

All API and MCP requests use Bearer tokens:

Authorization: Bearer <project-token>

Core facade resolves tokens to project context and caches services per project.

Multi-Store System

Projects use a hierarchical store structure:

  • DemuxStore - Routes operations to child stores
  • LocalStore A - Project-specific content
  • LocalStore B - Shared content across projects

Identity Map Caching

Stores cache entities to ensure single object instance per ID:

  • Cache checked before database queries
  • Mutations update cache after DB commit (via onSuccess callbacks)
  • Referential equality guaranteed

Field System

Entity fields provide metadata storage:

  • In-memory only (not persisted)
  • Store-level defaults
  • Single-valued and multi-valued fields
  • Accessed via FieldService

Development

See individual component READMEs:

  • /core/README.md - Core architecture
  • /core/entities/README.md - Domain entities
  • /core/services/README.md - Service layer
  • /core/stores/README.md - Data access layer
  • /api/README.md - REST API routes
  • /db/README.md - Database layer
  • /test/README.md - Testing guide