pnpm build- Build all packages (serialize first, then keyv, then all others)pnpm build:keyv:serialize- Build only the serialize packagepnpm build:keyv- Build only the keyv package
pnpm test- Run all tests across all packages with coveragepnpm -r --workspace-concurrency 1 test:ci- Run CI tests (same aspnpm test)pnpm test:services:start- Start Docker services for testing (requires Docker with host networking enabled)pnpm test:services:stop- Stop Docker services
Individual package tests:
cd {category}/{package-name} && pnpm test- Test specific package (e.g.,cd storage/redis && pnpm test)cd {category}/{package-name} && pnpm test:ci- Run CI tests for specific package
biome check- Check code with Biome linterbiome check --write- Fix auto-fixable issues- Individual packages use Biome for linting, configured with tabs and double quotes
- Start test services:
pnpm test:services:start - Run tests:
pnpm test - Build packages:
pnpm build - Stop test services:
pnpm test:services:stop
pnpm clean- Remove node_modules and generated files from all packages
- Root: Workspace configuration with pnpm
- core/keyv: Core Keyv library - the main key-value storage interface
- core/test-suite: Shared test suite (@keyv/test-suite) for API compliance testing
- serialization/serialize: Serialization utilities (@keyv/serialize) - used by core and adapters
- storage/: Storage adapters - Redis, MySQL, PostgreSQL, MongoDB, SQLite, Etcd, Memcache, Valkey, DynamoDB, BigMap
- compression/: Compression adapters - Brotli, Gzip, LZ4
- website: Documentation website
Core Keyv Class (core/keyv/src/index.ts):
- Extends EventManager for event emission
- Uses HooksManager for pre/post operation hooks
- Includes StatsManager for usage statistics
- Supports pluggable storage adapters, serialization, and compression
- Handles namespacing, TTL, and key prefixing
Storage Adapter Interface:
- Must implement:
get(),set(),delete(),clear() - Optional:
getMany(),setMany(),deleteMany(),has(),hasMany(),iterator(),disconnect() - Should emit events and extend EventEmitter-like interface
Serialization:
- Default uses
@keyv/serializepackage with JSON.stringify/parse - Compression adapters can be plugged in
- Data format:
{ value: T, expires?: number }
@keyv/serializemust be built first (used by keyv core)keyvcore must be built second (used by adapters)- All other packages can be built in parallel
- Docker is required for integration tests with databases/services
- Enable "host networking" in Docker settings for Redis cluster tests
- Test services are managed via scripts in
/scripts/directory - Each storage adapter should use
@keyv/test-suitefor compliance testing - Tests use Vitest with coverage reporting
- TypeScript with strict mode enabled
- Biome for linting and formatting
- Tab indentation, double quotes
- ES modules (
type: "module") - Build targets: CommonJS and ESM with TypeScript definitions
- Workspace packages use
workspace:^protocol - Core package (
keyv) depends only on@keyv/serialize - Storage adapters depend on
keyvas peer dependency - Test suite depends on
keyvand various testing utilities
Use the following format for pull request titles:
{package} - {type}: {description}
Examples:
sqlite - feat: Add WAL (Write-Ahead Logging) mode supportredis - fix: Connection timeout handlingkeyv - docs: Update API documentationmono - chore: Upgrade dependencies
Package names:
- Use the package name (e.g.,
sqlite,redis,postgres,keyv,serialize) - Use
monofor changes that affect the entire monorepo
Types:
feat: New featurefix: Bug fixdocs: Documentation changeschore: Maintenance tasks (dependencies, CI, etc.)refactor: Code refactoringtest: Test additions or changesperf: Performance improvements