@vltpkg/vsr 0.0.0-27 → 0.0.0-28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/DEPLOY.md +163 -0
  2. package/LICENSE +114 -10
  3. package/config.ts +221 -0
  4. package/dist/README.md +1 -1
  5. package/dist/bin/vsr.js +8 -6
  6. package/dist/index.js +3 -6
  7. package/dist/index.js.map +2 -2
  8. package/drizzle.config.js +40 -0
  9. package/info/COMPARISONS.md +37 -0
  10. package/info/CONFIGURATION.md +143 -0
  11. package/info/CONTRIBUTING.md +32 -0
  12. package/info/DATABASE_SETUP.md +108 -0
  13. package/info/GRANULAR_ACCESS_TOKENS.md +160 -0
  14. package/info/PROJECT_STRUCTURE.md +291 -0
  15. package/info/ROADMAP.md +27 -0
  16. package/info/SUPPORT.md +39 -0
  17. package/info/TESTING.md +301 -0
  18. package/info/USER_SUPPORT.md +31 -0
  19. package/package.json +49 -6
  20. package/scripts/build-assets.js +31 -0
  21. package/scripts/build-bin.js +63 -0
  22. package/src/assets/public/images/bg.png +0 -0
  23. package/src/assets/public/images/clients/logo-bun.png +0 -0
  24. package/src/assets/public/images/clients/logo-deno.png +0 -0
  25. package/src/assets/public/images/clients/logo-npm.png +0 -0
  26. package/src/assets/public/images/clients/logo-pnpm.png +0 -0
  27. package/src/assets/public/images/clients/logo-vlt.png +0 -0
  28. package/src/assets/public/images/clients/logo-yarn.png +0 -0
  29. package/src/assets/public/images/favicon/apple-touch-icon.png +0 -0
  30. package/src/assets/public/images/favicon/favicon-96x96.png +0 -0
  31. package/src/assets/public/images/favicon/favicon.ico +0 -0
  32. package/src/assets/public/images/favicon/favicon.svg +3 -0
  33. package/src/assets/public/images/favicon/site.webmanifest +21 -0
  34. package/src/assets/public/images/favicon/web-app-manifest-192x192.png +0 -0
  35. package/src/assets/public/images/favicon/web-app-manifest-512x512.png +0 -0
  36. package/src/assets/public/styles/styles.css +231 -0
  37. package/src/bin/demo/package.json +6 -0
  38. package/src/bin/demo/vlt.json +1 -0
  39. package/src/bin/vsr.ts +496 -0
  40. package/src/db/client.ts +590 -0
  41. package/src/db/migrations/0000_faulty_ricochet.sql +14 -0
  42. package/src/db/migrations/0000_initial.sql +29 -0
  43. package/src/db/migrations/0001_uuid_validation.sql +35 -0
  44. package/src/db/migrations/0001_wealthy_magdalene.sql +7 -0
  45. package/src/db/migrations/drop.sql +3 -0
  46. package/src/db/migrations/meta/0000_snapshot.json +104 -0
  47. package/src/db/migrations/meta/0001_snapshot.json +155 -0
  48. package/src/db/migrations/meta/_journal.json +20 -0
  49. package/src/db/schema.ts +43 -0
  50. package/src/index.ts +434 -0
  51. package/src/middleware/config.ts +79 -0
  52. package/src/middleware/telemetry.ts +43 -0
  53. package/src/queue/index.ts +97 -0
  54. package/src/routes/access.ts +852 -0
  55. package/src/routes/docs.ts +63 -0
  56. package/src/routes/misc.ts +469 -0
  57. package/src/routes/packages.ts +2823 -0
  58. package/src/routes/ping.ts +39 -0
  59. package/src/routes/search.ts +131 -0
  60. package/src/routes/static.ts +74 -0
  61. package/src/routes/tokens.ts +259 -0
  62. package/src/routes/users.ts +68 -0
  63. package/src/utils/auth.ts +202 -0
  64. package/src/utils/cache.ts +587 -0
  65. package/src/utils/config.ts +50 -0
  66. package/src/utils/database.ts +69 -0
  67. package/src/utils/docs.ts +146 -0
  68. package/src/utils/packages.ts +453 -0
  69. package/src/utils/response.ts +125 -0
  70. package/src/utils/routes.ts +64 -0
  71. package/src/utils/spa.ts +52 -0
  72. package/src/utils/tracing.ts +52 -0
  73. package/src/utils/upstream.ts +172 -0
  74. package/tsconfig.json +16 -0
  75. package/tsconfig.worker.json +3 -0
  76. package/typedoc.mjs +2 -0
  77. package/types.ts +598 -0
  78. package/vitest.config.ts +25 -0
  79. package/vlt.json.example +56 -0
  80. package/wrangler.json +65 -0
@@ -0,0 +1,291 @@
1
+ # VSR Project Directory Structure
2
+
3
+ **VSR** is a minimal "npm-compatible" registry that replicates core
4
+ features of `registry.npmjs.org` while adding new capabilities. It's
5
+ built to run on Cloudflare Workers with D1 database and R2 storage.
6
+
7
+ ## 📁 Root Directory
8
+
9
+ ```
10
+ registry/
11
+ ├── config.ts # Global application configuration
12
+ ├── package.json # NPM package definition & scripts
13
+ ├── wrangler.json # Cloudflare Workers deployment config
14
+ ├── drizzle.config.js # Database ORM configuration
15
+ ├── tsconfig.worker.json # TypeScript config for Workers environment
16
+ ├── types.ts # Shared TypeScript type definitions
17
+ ├── README.md # Project documentation & setup guide
18
+ ├── CONTRIBUTING.md # Development guidelines & workflow
19
+ ├── LICENSE # FSL-1.1-MIT license
20
+ └── src/ # Source code directory
21
+ ```
22
+
23
+ ### Configuration Files
24
+
25
+ - **`config.ts`** - Central configuration hub containing:
26
+ - API documentation settings
27
+ - Upstream registry definitions (npm, local)
28
+ - Authentication domains and redirect URIs
29
+ - Cookie options and security settings
30
+ - Development server configuration
31
+
32
+ - **`wrangler.json`** - Cloudflare Workers configuration:
33
+ - D1 database bindings for SQLite storage
34
+ - R2 bucket bindings for package tarballs
35
+ - Queue configurations for background processing
36
+ - Asset serving and development settings
37
+
38
+ - **`package.json`** - Project metadata and tooling:
39
+ - Build scripts for dist creation and asset copying
40
+ - Database management commands (push, migrate, studio)
41
+ - Development server orchestration
42
+ - TypeScript compilation for both Node.js and Workers
43
+
44
+ ## 📁 Source Code (`src/`)
45
+
46
+ ```
47
+ src/
48
+ ├── index.ts # Main application entry point
49
+ ├── api.ts # OpenAPI specification
50
+ ├── routes/ # HTTP route handlers
51
+ ├── utils/ # Shared utility functions
52
+ ├── db/ # Database layer
53
+ ├── assets/ # Static files & frontend
54
+ ├── bin/ # CLI executables
55
+ └── schemas/ # Validation schemas
56
+ ```
57
+
58
+ ### Core Application
59
+
60
+ - **`index.ts`** - Main Hono application setup:
61
+ - Middleware stack (auth, logging, CORS, security)
62
+ - Route mounting and organization
63
+ - Queue consumer for background package refreshing
64
+ - Health checks and API documentation endpoints
65
+
66
+ - **`api.ts`** - OpenAPI specification:
67
+ - REST API definitions for all endpoints
68
+ - Request/response schemas
69
+ - Authentication requirements
70
+ - Used by Scalar for auto-generated documentation
71
+
72
+ ## 📁 Route Handlers (`src/routes/`)
73
+
74
+ ```
75
+ routes/
76
+ ├── users.ts # User profile management
77
+ ├── tokens.ts # Authentication token CRUD
78
+ ├── packages.ts # Package operations (45KB - core logic)
79
+ ├── search.ts # Package search & discovery
80
+ ├── auth.ts # OAuth authentication flows
81
+ ├── access.ts # Access control & permissions
82
+ └── static.ts # Static asset serving
83
+ ```
84
+
85
+ ### Route Responsibilities
86
+
87
+ - **`packages.ts`** (Primary) - Core package registry functionality:
88
+ - Package publishing and unpublishing
89
+ - Version management and dist-tags
90
+ - Tarball upload/download via R2
91
+ - Upstream registry proxying for missing packages
92
+ - Package metadata validation and transformation
93
+
94
+ - **`tokens.ts`** - Granular Access Token (GAT) management:
95
+ - Token creation with scoped permissions
96
+ - CRUD operations for user tokens
97
+ - Scope validation (pkg:read/write, user:read/write)
98
+
99
+ - **`auth.ts`** - Authentication workflows:
100
+ - OAuth callback handling
101
+ - Session management
102
+ - Login/logout flows
103
+
104
+ - **`access.ts`** - Fine-grained access control:
105
+ - Package-level permissions
106
+ - Collaborator management
107
+ - Access list operations
108
+
109
+ - **`search.ts`** - Package discovery:
110
+ - Text-based package searching
111
+ - Filtering and pagination
112
+ - Integration with upstream registries
113
+
114
+ - **`users.ts`** - User management:
115
+ - Profile retrieval (`/-/whoami`)
116
+ - User information endpoints
117
+
118
+ - **`static.ts`** - Asset delivery:
119
+ - Favicon serving
120
+ - CSS stylesheet delivery
121
+ - Image asset routing
122
+ - robots.txt and manifest files
123
+
124
+ ## 📁 Utilities (`src/utils/`)
125
+
126
+ ```
127
+ utils/
128
+ ├── auth.ts # Authentication & token verification
129
+ ├── cache.ts # Package caching strategies (13KB)
130
+ ├── database.ts # Database connection middleware
131
+ ├── packages.ts # Package validation & processing (13KB)
132
+ ├── response.ts # HTTP response formatting
133
+ ├── routes.ts # Route middleware & guards
134
+ ├── spa.ts # Single Page Application serving
135
+ ├── tracing.ts # Request monitoring & performance
136
+ └── upstream.ts # Registry proxying & fallback
137
+ ```
138
+
139
+ ### Utility Functions
140
+
141
+ - **`cache.ts`** - Intelligent caching system:
142
+ - Package metadata caching from upstream registries
143
+ - Version-specific caching strategies
144
+ - Cache invalidation and refresh logic
145
+ - Background queue integration for cache warming
146
+
147
+ - **`packages.ts`** - Package processing utilities:
148
+ - NPM package validation
149
+ - Tarball extraction and analysis
150
+ - Manifest transformation and normalization
151
+ - Semver handling and version resolution
152
+
153
+ - **`upstream.ts`** - Multi-registry support:
154
+ - Configuration-driven upstream definitions
155
+ - Fallback logic for missing packages
156
+ - Request proxying and response transformation
157
+ - Error handling for upstream failures
158
+
159
+ - **`auth.ts`** - Security utilities:
160
+ - Bearer token verification
161
+ - Scope-based authorization
162
+ - JWT handling and validation
163
+
164
+ ## 📁 Database Layer (`src/db/`)
165
+
166
+ ```
167
+ db/
168
+ ├── client.ts # Database client & operations
169
+ ├── schema.ts # Drizzle schema definitions
170
+ └── migrations/ # Database migrations
171
+ ├── 0000_initial.sql # Base schema creation
172
+ ├── 0001_uuid_validation.sql # UUID constraints
173
+ ├── drop.sql # Development reset script
174
+ └── meta/ # Drizzle migration metadata
175
+ ├── _journal.json # Migration history
176
+ ├── 0000_snapshot.json # Schema snapshots
177
+ └── 0001_snapshot.json
178
+ ```
179
+
180
+ ### Database Architecture
181
+
182
+ - **`schema.ts`** - Core data model:
183
+ - `packages` table: Package metadata and tags
184
+ - `versions` table: Version-specific manifests
185
+ - `tokens` table: Authentication tokens with scoped permissions
186
+ - Origin tracking (local vs upstream)
187
+ - Caching timestamps for upstream data
188
+
189
+ - **`client.ts`** - Database operations:
190
+ - Drizzle ORM integration
191
+ - CRUD operations for all entities
192
+ - Transaction management
193
+ - Connection pooling for Workers environment
194
+
195
+ ## 📁 Static Assets (`src/assets/`)
196
+
197
+ ```
198
+ assets/
199
+ └── public/
200
+ ├── images/
201
+ │ ├── bg.png # Background image
202
+ │ ├── clients/ # Package manager logos
203
+ │ │ ├── logo-npm.png
204
+ │ │ ├── logo-yarn.png
205
+ │ │ ├── logo-pnpm.png
206
+ │ │ ├── logo-bun.png
207
+ │ │ ├── logo-deno.png
208
+ │ │ └── logo-vlt.png
209
+ │ └── favicon/ # Browser icons (multiple formats)
210
+ │ ├── favicon.ico
211
+ │ ├── favicon.svg
212
+ │ ├── apple-touch-icon.png
213
+ │ ├── favicon-96x96.png
214
+ │ ├── site.webmanifest
215
+ │ ├── web-app-manifest-192x192.png
216
+ │ └── web-app-manifest-512x512.png
217
+ └── styles/
218
+ └── styles.css # Application CSS
219
+ ```
220
+
221
+ ### Asset Organization
222
+
223
+ - **`images/clients/`** - Package manager branding:
224
+ - Logos for supported package managers
225
+ - Used in web interface for client recognition
226
+ - Consistent sizing and format
227
+
228
+ - **`images/favicon/`** - Browser integration:
229
+ - Multiple icon formats for cross-platform support
230
+ - Progressive Web App manifest
231
+ - Apple touch icons for iOS devices
232
+
233
+ ## 📁 CLI Tools (`src/bin/`)
234
+
235
+ ```
236
+ bin/
237
+ ├── vsr.ts # Main CLI entry point
238
+ └── demo/ # Demo project workspace
239
+ ├── package.json # Demo dependencies
240
+ └── vlt.json # VLT configuration
241
+ ```
242
+
243
+ ### Command Line Interface
244
+
245
+ - **`vsr.ts`** - Development server orchestration:
246
+ - Spawns both the vlt daemon (port 3000) and wrangler dev
247
+ (port 1337)
248
+ - Manages local development environment
249
+ - Debug mode for verbose logging
250
+ - Automatic path resolution for monorepo structure
251
+
252
+ - **`demo/`** - Testing workspace:
253
+ - Minimal project for vlt server requirements
254
+ - Used during development to simulate real package operations
255
+ - Contains basic package.json and vlt configuration
256
+
257
+ ## 📁 Validation (`src/schemas/`)
258
+
259
+ ```
260
+ schemas/
261
+ └── [Currently empty - reserved for future validation schemas]
262
+ ```
263
+
264
+ **Purpose**: Reserved directory for request/response validation
265
+ schemas, likely to be populated with Zod or similar validation
266
+ libraries.
267
+
268
+ ## 🏗️ Architecture Overview
269
+
270
+ ### Request Flow
271
+
272
+ 1. **Static Assets** → Direct serving via Cloudflare Workers
273
+ 2. **Package Requests** → Local DB check → Upstream fallback if needed
274
+ 3. **Authentication** → Bearer token validation → Scope checking
275
+ 4. **Publishing** → Validation → R2 storage → DB metadata update
276
+
277
+ ### Data Flow
278
+
279
+ - **Local Packages**: Stored in D1 (metadata) + R2 (tarballs)
280
+ - **Upstream Packages**: Cached in D1 with TTL, proxied from npm
281
+ - **Background Jobs**: Queue-based cache refresh for popular packages
282
+
283
+ ### Security Model
284
+
285
+ - **Granular Access Tokens**: Scoped permissions per package/user
286
+ - **Origin Tracking**: Distinguish local vs upstream packages
287
+ - **Scope Validation**: Package-level and user-level access control
288
+
289
+ This architecture provides a scalable, serverless npm registry that
290
+ can serve as both a private registry and an intelligent proxy to
291
+ upstream registries like npmjs.org.
@@ -0,0 +1,27 @@
1
+ ### Roadmap
2
+
3
+ #### v1.0.0
4
+
5
+ | Status | Feature |
6
+ | :----: | :---------------------------------------------------- |
7
+ | ⏳ | web: user login (ex. `npm login` / `--auth-type=web`) |
8
+ | ⏳ | web: user account management (`hosted`) |
9
+ | ⏳ | web: user registration (`hosted`) |
10
+ | ⏳ | web: admin user management (`hosted`) |
11
+ | ⏳ | web: package pages |
12
+ | ⏳ | web: search |
13
+ | ⏳ | api: rate-limiting |
14
+
15
+ #### v1.x
16
+
17
+ | Status | Feature |
18
+ | :----: | :---------------------------------------- |
19
+ | 🕤 | api: package insights (powered by socket) |
20
+ | 🕤 | api: audit (powered by socket) |
21
+ | 🕤 | mfa access provisioning |
22
+ | 🕤 | orgs |
23
+ | 🕤 | teams |
24
+ | 🕤 | staging |
25
+ | 🕤 | events/hooks |
26
+ | 🕤 | plugins/middleware |
27
+ | 🕤 | variants/distributions |
@@ -0,0 +1,39 @@
1
+ # Supported `npm` Client Commands
2
+
3
+ | Support | Commannd |
4
+ | :-----: | :-------------------------------------------------------------------------------------- |
5
+ | ✅ | `access` |
6
+ | ✅ | `access list packages` |
7
+ | ✅ | `access get status` |
8
+ | ✅ | `access set status` |
9
+ | 🕤 | `access set mfa` |
10
+ | ✅ | `access grant` |
11
+ | ✅ | `access revoke` |
12
+ | 🕤 | `adduser` - `PUT /-/org/@<org>/<user>`: Adds/updates a user (requires admin privileges) |
13
+ | ⏳ | `audit` |
14
+ | ✅ | `bugs` |
15
+ | ✅ | `dist-tag add` |
16
+ | ✅ | `dist-tag rm` |
17
+ | ✅ | `dist-tag ls` |
18
+ | ✅ | `deprecate` |
19
+ | ✅ | `docs` |
20
+ | ✅ | `exec` |
21
+ | ✅ | `install` |
22
+ | ⏳ | `login` |
23
+ | ⏳ | `logout` |
24
+ | 🕤 | `org` |
25
+ | ✅ | `outdated` |
26
+ | 🕤 | `owner add` |
27
+ | 🕤 | `owner rm` |
28
+ | 🕤 | `owner ls` |
29
+ | ✅ | `ping` |
30
+ | 🕤 | `profile enable-2fa` |
31
+ | 🕤 | `profile disable-2fa` |
32
+ | ✅ | `profile get` |
33
+ | 🕤 | `profile set` - `PUT /-/npm/v1/user`: Updates a user (requires auth) |
34
+ | ✅ | `publish` |
35
+ | ✅ | `repo` |
36
+ | ✅ | `search` |
37
+ | 🕤 | `team` |
38
+ | ✅ | `view` |
39
+ | ✅ | `whoami` |
@@ -0,0 +1,301 @@
1
+ # VSR Registry Tests
2
+
3
+ This directory contains comprehensive tests for the VSR (vlt-specific
4
+ registry) covering all endpoints and functionality.
5
+
6
+ ## Test Structure
7
+
8
+ The test suite uses a hybrid approach combining both mocked and real
9
+ Cloudflare Workers environments for optimal coverage and performance.
10
+
11
+ ### Core Package Tests
12
+
13
+ #### `manifest.test.ts`
14
+
15
+ **Package manifest endpoint tests** covering both local/private
16
+ packages and upstream registry public packages.
17
+
18
+ **Covers:**
19
+
20
+ - Local package manifests (packuments, versions, tarballs)
21
+ - Upstream registry manifests (NPM, JSR, Custom)
22
+ - Version-specific requests and semver handling
23
+ - Error handling for invalid packages and versions
24
+ - Response structure validation
25
+
26
+ #### `packaument.test.ts`
27
+
28
+ **Package packument endpoint tests** for full package information
29
+ including all versions and metadata.
30
+
31
+ **Covers:**
32
+
33
+ - Local/private package packuments
34
+ - Upstream public package packuments (NPM, JSR, Custom)
35
+ - Version range filtering and semver queries
36
+ - Response structure validation (name, dist-tags, versions, time)
37
+ - Error handling and special package names
38
+ - Performance and caching behavior
39
+
40
+ ### Utility Endpoint Tests
41
+
42
+ #### `ping.test.ts`
43
+
44
+ **Health check endpoint tests** for both root and upstream registries.
45
+
46
+ **Covers:**
47
+
48
+ - Root registry ping (`/-/ping`)
49
+ - Upstream registry ping (`/{upstream}/-/ping`)
50
+ - NPM compatibility headers
51
+ - Response format validation
52
+
53
+ #### `whoami.test.ts`
54
+
55
+ **User identity endpoint tests** for authentication and user
56
+ information.
57
+
58
+ **Covers:**
59
+
60
+ - Root registry whoami (`/-/whoami`)
61
+ - Upstream registry whoami (`/{upstream}/-/whoami`)
62
+ - Authentication behavior (authenticated vs unauthenticated)
63
+ - Response format consistency
64
+ - Error handling for invalid tokens
65
+
66
+ #### `search.test.ts`
67
+
68
+ **Package search endpoint tests** for finding packages across
69
+ registries.
70
+
71
+ **Covers:**
72
+
73
+ - Root registry search (`/-/search`)
74
+ - Upstream registry search (`/{upstream}/-/search`)
75
+ - Query parameter handling (text, size, from, quality, popularity,
76
+ maintenance)
77
+ - Search response structure and pagination
78
+ - Legacy API redirects (`/-/v1/search`)
79
+ - Error handling and performance limits
80
+
81
+ ### Management Endpoint Tests
82
+
83
+ #### `tokens.test.ts`
84
+
85
+ **Token management endpoint tests** for authentication token CRUD
86
+ operations.
87
+
88
+ **Covers:**
89
+
90
+ - Token listing (`GET /-/tokens`)
91
+ - Token creation (`POST /-/tokens`)
92
+ - Token updates (`PUT /-/tokens`)
93
+ - Token deletion (`DELETE /-/tokens/{token}`)
94
+ - Upstream token management
95
+ - Authentication and authorization
96
+ - Request validation and error handling
97
+
98
+ #### `access.test.ts`
99
+
100
+ **Access control endpoint tests** for package permissions and
101
+ collaborator management.
102
+
103
+ **Covers:**
104
+
105
+ - Package access status (`/-/package/{pkg}/access`)
106
+ - Collaborator management
107
+ (`/-/package/{pkg}/collaborators/{username}`)
108
+ - Scoped package access control
109
+ - Package list access (`/-/package/list`)
110
+ - Authentication and authorization levels
111
+ - Permission validation
112
+
113
+ #### `dist-tags.test.ts`
114
+
115
+ **Distribution tags endpoint tests** for package version tagging.
116
+
117
+ **Covers:**
118
+
119
+ - Dist-tag retrieval (`/-/package/{pkg}/dist-tags`)
120
+ - Dist-tag creation/updates (`PUT /-/package/{pkg}/dist-tags/{tag}`)
121
+ - Dist-tag deletion (`DELETE /-/package/{pkg}/dist-tags/{tag}`)
122
+ - Semver validation and tag name validation
123
+ - Authentication and ownership checks
124
+ - Complete dist-tag lifecycle operations
125
+
126
+ ### Security and Audit Tests
127
+
128
+ #### `audit.test.ts`
129
+
130
+ **Security audit endpoint tests** for vulnerability scanning.
131
+
132
+ **Covers:**
133
+
134
+ - Root registry audit (`/-/npm/audit`)
135
+ - Upstream registry audit (`/{upstream}/-/npm/audit`)
136
+ - Package lock format support (v1, v2, v3)
137
+ - Dependency tree validation
138
+ - Legacy API redirects
139
+ - Request validation and error handling
140
+ - Audit implementation status
141
+
142
+ ### Infrastructure Tests
143
+
144
+ #### `static.test.ts`
145
+
146
+ **Static asset endpoint tests** for web interface and public files.
147
+
148
+ **Covers:**
149
+
150
+ - Public assets (`/public/*`)
151
+ - Special files (`/favicon.ico`, `/robots.txt`, `/manifest.json`)
152
+ - Content-type headers for different file types
153
+ - Cache control and compression
154
+ - Security considerations (directory traversal prevention)
155
+ - Performance optimization (range requests, conditional requests)
156
+
157
+ #### `dashboard.test.ts`
158
+
159
+ **Dashboard endpoint tests** for daemon-mode web interface data.
160
+
161
+ **Covers:**
162
+
163
+ - Dashboard configuration (`/dashboard.json`)
164
+ - Application data (`/app-data.json`)
165
+ - Daemon enable/disable behavior
166
+ - Data structure validation
167
+ - Feature flag integration
168
+ - Performance and concurrent request handling
169
+
170
+ ## Testing Approach
171
+
172
+ ### Hybrid Testing Strategy
173
+
174
+ The test suite uses two complementary approaches:
175
+
176
+ 1. **Mocked Environment Tests** (`app.request()` with `mockEnv`)
177
+ - Used for complex endpoints (manifest, packument, search, tokens,
178
+ access, etc.)
179
+ - Fast execution with comprehensive mocking
180
+ - Reliable and deterministic results
181
+ - Covers edge cases and error conditions
182
+
183
+ 2. **Real Cloudflare Workers Tests** (`SELF.fetch()` with real
184
+ bindings)
185
+ - Used for simple endpoints (ping, whoami)
186
+ - Real database and environment integration
187
+ - End-to-end validation with actual Workers runtime
188
+ - Configured via `@cloudflare/vitest-pool-workers`
189
+
190
+ ### Mock Environment Structure
191
+
192
+ ```typescript
193
+ const mockEnv = {
194
+ DB: {
195
+ // Minimal D1 interface with Drizzle ORM compatibility
196
+ prepare: () => ({ bind: () => ({ get, all, run, raw }) }),
197
+ batch: () => Promise.resolve([]),
198
+ exec: () => Promise.resolve(),
199
+ },
200
+ BUCKET: { get, put, delete },
201
+ KV: { get, put, delete },
202
+ // Additional bindings as needed
203
+ }
204
+ ```
205
+
206
+ ## Running Tests
207
+
208
+ ```bash
209
+ # Run all tests
210
+ pnpm test
211
+
212
+ # Run specific test files
213
+ pnpm test test/manifest.test.ts
214
+ pnpm test test/tokens.test.ts
215
+ pnpm test test/search.test.ts
216
+
217
+ # Run tests in watch mode
218
+ pnpm test --watch
219
+
220
+ # Run tests with coverage
221
+ pnpm test --coverage
222
+
223
+ # Run linting
224
+ pnpm lint
225
+ ```
226
+
227
+ ## Test Results
228
+
229
+ Current test coverage includes **8 comprehensive test files** with
230
+ **300+ individual tests**:
231
+
232
+ - ✅ **manifest.test.ts** - 33 tests (Package manifests)
233
+ - ✅ **packaument.test.ts** - 40 tests (Package packuments)
234
+ - ✅ **ping.test.ts** - 5 tests (Health checks)
235
+ - ✅ **whoami.test.ts** - 10 tests (User identity)
236
+ - ✅ **search.test.ts** - 50+ tests (Package search)
237
+ - ✅ **tokens.test.ts** - 40+ tests (Token management)
238
+ - ✅ **access.test.ts** - 60+ tests (Access control)
239
+ - ✅ **dist-tags.test.ts** - 50+ tests (Distribution tags)
240
+ - ✅ **audit.test.ts** - 40+ tests (Security audits)
241
+ - ✅ **static.test.ts** - 60+ tests (Static assets)
242
+ - ✅ **dashboard.test.ts** - 40+ tests (Dashboard data)
243
+
244
+ ## Key Features Tested
245
+
246
+ ### NPM Registry Compatibility
247
+
248
+ - Full npm client compatibility for all utility endpoints
249
+ - Proper HTTP status codes and response formats
250
+ - Legacy API redirect support
251
+ - Semver validation and handling
252
+
253
+ ### Multi-Registry Support
254
+
255
+ - Root/local registry functionality
256
+ - Upstream registry proxying (NPM, JSR, Custom)
257
+ - Registry-specific endpoint behavior
258
+ - Upstream configuration validation
259
+
260
+ ### Security and Authentication
261
+
262
+ - Token-based authentication
263
+ - Package access control and permissions
264
+ - Collaborator management
265
+ - Security audit functionality
266
+ - Input validation and sanitization
267
+
268
+ ### Performance and Reliability
269
+
270
+ - Response time validation
271
+ - Concurrent request handling
272
+ - Error handling and edge cases
273
+ - Cache control and optimization
274
+ - Resource limits and validation
275
+
276
+ ## Configuration
277
+
278
+ Tests are configured in `vitest.config.ts` with:
279
+
280
+ - **Cloudflare Workers pool** for real environment testing
281
+ - **30-second timeout** for upstream requests
282
+ - **Real bindings setup** in `test/setup.ts`
283
+ - **Database schema creation** for isolated test environments
284
+ - **Environment variable configuration**
285
+
286
+ ## Future Improvements
287
+
288
+ 1. **Enhanced Integration Testing**
289
+ - More real Cloudflare Workers tests as the framework matures
290
+ - End-to-end workflow testing
291
+ - Performance benchmarking
292
+
293
+ 2. **Advanced Test Scenarios**
294
+ - Load testing for high-traffic scenarios
295
+ - Chaos engineering for resilience testing
296
+ - Cross-registry interaction testing
297
+
298
+ 3. **Test Automation**
299
+ - Automated test generation for new endpoints
300
+ - Contract testing for API compatibility
301
+ - Visual regression testing for web interface
@@ -0,0 +1,31 @@
1
+ # Support
2
+
3
+ ## News
4
+
5
+ - Home: <https://vlt.sh>
6
+ - Blog: <https://blog.vlt.sh/>
7
+
8
+ ## Official Documentation
9
+
10
+ - CLI: <https://docs.vlt.sh/cli>
11
+ - VSR: <https://docs.vlt.sh/registry>
12
+
13
+ ## Social Media
14
+
15
+ - GitHub: <https://github.com/vltpkg>
16
+ - Linkedin: <https://www.linkedin.com/company/vltpkg/>
17
+ - Bluesky: <https://bsky.app/profile/vlt.sh>
18
+ - Twitter: <https://x.com/vltpkg>
19
+ - Discord: <https://discord.gg/vltpkg>
20
+ - Youtube: <https://www.youtube.com/@vltpkg>
21
+
22
+ ## Public Calendar
23
+
24
+ - gCal:
25
+ <https://calendar.google.com/calendar/embed?src=c_ee5f7f2a875caac1c7a90183d7faf31f2fe0e22b94aca147f005bfb3e0c7e072%40group.calendar.google.com>
26
+ - iCal:
27
+ <https://calendar.google.com/calendar/ical/c_ee5f7f2a875caac1c7a90183d7faf31f2fe0e22b94aca147f005bfb3e0c7e072%40group.calendar.google.com/public/basic.ics>
28
+
29
+ ## More
30
+
31
+ - Package Managers Benchmarks: <https://benchmarks.vlt.sh>