Skip to content

Commit 86a875d

Browse files
v1rtlclaude
andcommitted
docs: add CLAUDE.md for Claude Code guidance
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8171bac commit 86a875d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

CLAUDE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
tinyws is a minimal WebSocket middleware for Node.js based on the `ws` library. It adds a `req.ws()` method to requests that resolves to a WebSocket connection when an upgrade request is received. Framework-agnostic (works with tinyhttp, express, polka).
8+
9+
## Commands
10+
11+
- **Build**: `pnpm build` - Compiles TypeScript to `dist/`
12+
- **Test**: `bun test` - Runs tests with Bun's test runner (tests use `bun:test`)
13+
- **Test with coverage**: `pnpm test:coverage` - Runs tests with c8 coverage
14+
- **Lint**: `pnpm lint` - Uses ESLint
15+
- **Format**: `pnpm format` - Uses Prettier
16+
17+
## Architecture
18+
19+
Single-file middleware in `src/index.ts`:
20+
- Exports `tinyws()` factory function that returns async middleware
21+
- Exports `TinyWSRequest` interface extending `http.IncomingMessage` with `ws()` method
22+
- Middleware checks for WebSocket upgrade header and attaches `req.ws` function
23+
- `req.ws()` returns a Promise that resolves to a WebSocket instance after `handleUpgrade`
24+
- Accepts optional `ServerOptions` and existing `WebSocketServer` instance
25+
26+
## Code Style
27+
28+
- Pure ESM (`"type": "module"`)
29+
- Biome for formatting (2 spaces, single quotes, no trailing commas, no semicolons)
30+
- Line width 120 characters

0 commit comments

Comments
 (0)