Spool SDK

9-package TypeScript SDK for NestJS + Fastify backends

9 independent TypeScript packages for NestJS + Fastify.

  • Request context with W3C traceparent, structured JSON logging
  • AES-256-GCM encryption, Zod validation pipes
  • Redis distributed locks, JWT auth with jose
  • Prisma lifecycle management, shared utilities
  • 7 of 9 packages zero-dependency
  • TypeScript strict mode, ESM + CJS dual format
Private RepositoryThis is a private repository. You need collaborator access to view the source code on GitHub.
9
Packages
161
Tests
7/9
Zero-dep
0.1.0
Version
Stable
Status

Tech Stack

TypeScriptNestJS 11Fastify 5pnpm WorkspacesTurborepoVitest

How It Works

Ecosystem
🔧
Spool SDK
NestJS + Fastify
9 packages
BACKEND
🍎
Weave SDK
iOS · Swift
13 modules
🤖
Warp SDK
Android · Kotlin
13 modules
🌐
Loom SDK
React · Next.js
9 modules
ErrorCode enum + Response envelope shared 1:1 across all SDKs — Spool is the source of truth
Packages (9)
🔧
@spool/utils
Redaction, sanitize, IP, trace
🗄
@spool/prisma
PrismaService lifecycle
🔐
@spool/crypto
AES-256-GCM, HMAC, API keys
@spool/validation
ZodValidationPipe, sanitizer
🌐
@spool/http
AppException, ErrorCode, Filter
📦
@spool/redis
Distributed lock, rate limit
🔑
@spool/auth
JWT (jose), session store
@spool/core
RequestContext, W3C trace
→ @spool/utils
📝
@spool/logger
Structured JSON logging
→ @spool/utils
7 of 9 packages have zero internal dependencies

Features

Modular Architecture

9 independent packages with opt-in imports.

  • 7 of 9 have zero internal dependencies
  • Only 2 edges: @spool/utils used by @spool/core and @spool/logger
  • Each package has its own README with full API reference

@spool/core -Request Context

Request-scoped context middleware.

  • RequestContextMiddleware and RequestContextService
  • W3C traceparent propagation for distributed tracing
  • Extracts client IP, request ID, and user agent automatically

@spool/http -Error Handling

Consistent error handling layer.

  • AppException with typed ErrorCodes
  • GlobalExceptionFilter for standardized error responses
  • ResponseInterceptor for success/error envelope
  • Handles Fastify and NestJS errors uniformly

@spool/logger -Structured Logging

Request-scoped structured logging.

  • LoggerService (scoped) and AppLoggerService (singleton)
  • JSON output with trace context
  • Sensitive field redaction, configurable log levels

@spool/redis -Cache & Locks

ioredis wrapper with distributed locking.

  • RedisService with Lua-script-based distributed locks
  • Built-in rate limiting with sliding window counters

@spool/crypto -Encryption

Node.js native crypto utilities.

  • AES-256-GCM encryption/decryption
  • HMAC-SHA256 signing
  • Secure API key generation, zero dependencies

@spool/auth -JWT & Sessions

JWT service built on jose.

  • HS256 signing with token generation, verification, and refresh
  • SessionStore and RefreshTokenStore for pluggable storage backends

@spool/validation

Zod-based validation for NestJS.

  • ZodValidationPipe with formatted error messages
  • Input sanitization middleware
  • Type-safe request/response validation

@spool/prisma

Prisma lifecycle management.

  • PrismaServiceBase with clean connect/disconnect
  • Health check endpoint integration
  • Graceful shutdown handling

@spool/utils

Shared utility functions.

  • Redaction, sanitization, client IP extraction
  • Percentile calculation, W3C trace context