@hammr/cdn 1.0.1 โ 1.0.2
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.
- package/README.md +22 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
11
|
+
- **Content-Addressable** - Automatic SHA256 hashing via [@hammr/normalizer](https://www.npmjs.com/package/@hammr/normalizer)
|
|
12
|
+
- **Idempotent Uploads** - Same content = same hash, stored once
|
|
13
|
+
- **Storage Abstraction** - R2, S3, Memory, FileSystem (bring your own!)
|
|
14
|
+
- **Auto Content-Type Detection** - 40+ file types recognized automatically
|
|
15
|
+
- **Immutable Artifacts** - Hash-based URLs with aggressive caching
|
|
16
|
+
- **HTTP Request Handler** - Drop-in handler for Cloudflare Workers
|
|
17
|
+
- **Production-Ready** - CORS, ETag, Cache-Control, error handling
|
|
18
|
+
- **Zero Config** - Works out of the box with sensible defaults
|
|
19
|
+
- **100% Test Coverage** - Fully tested and type-safe
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
npm install @
|
|
24
|
+
npm install @hammr/cdn
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Quick Start
|
|
@@ -29,7 +29,7 @@ npm install @sygnl/cdn
|
|
|
29
29
|
### Cloudflare Workers (R2 Storage)
|
|
30
30
|
|
|
31
31
|
```typescript
|
|
32
|
-
import { CDN, R2Storage } from '@
|
|
32
|
+
import { CDN, R2Storage } from '@hammr/cdn';
|
|
33
33
|
|
|
34
34
|
export default {
|
|
35
35
|
async fetch(request: Request, env: Env) {
|
|
@@ -46,7 +46,7 @@ export default {
|
|
|
46
46
|
### Programmatic Usage
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
|
-
import { CDN, MemoryStorage } from '@
|
|
49
|
+
import { CDN, MemoryStorage } from '@hammr/cdn';
|
|
50
50
|
|
|
51
51
|
const cdn = new CDN({
|
|
52
52
|
storage: new MemoryStorage(),
|
|
@@ -202,7 +202,7 @@ export default {
|
|
|
202
202
|
### R2Storage (Cloudflare R2)
|
|
203
203
|
|
|
204
204
|
```typescript
|
|
205
|
-
import { CDN, R2Storage } from '@
|
|
205
|
+
import { CDN, R2Storage } from '@hammr/cdn';
|
|
206
206
|
|
|
207
207
|
const cdn = new CDN({
|
|
208
208
|
storage: new R2Storage(env.ARTIFACTS), // R2 binding from Cloudflare Workers
|
|
@@ -223,7 +223,7 @@ bucket_name = "my-cdn-artifacts"
|
|
|
223
223
|
### MemoryStorage (Development/Testing)
|
|
224
224
|
|
|
225
225
|
```typescript
|
|
226
|
-
import { CDN, MemoryStorage } from '@
|
|
226
|
+
import { CDN, MemoryStorage } from '@hammr/cdn';
|
|
227
227
|
|
|
228
228
|
const cdn = new CDN({
|
|
229
229
|
storage: new MemoryStorage(),
|
|
@@ -402,7 +402,7 @@ console.log(artifact.metadata.customMetadata.productId); // โ prod_123
|
|
|
402
402
|
### Verify Upload Integrity
|
|
403
403
|
|
|
404
404
|
```typescript
|
|
405
|
-
import { sha256 } from '@
|
|
405
|
+
import { sha256 } from '@hammr/normalizer';
|
|
406
406
|
|
|
407
407
|
// Client computes hash before upload
|
|
408
408
|
const clientHash = await sha256(Array.from(new Uint8Array(fileBytes))
|
|
@@ -477,7 +477,7 @@ npm install @hammr/cdn
|
|
|
477
477
|
```toml
|
|
478
478
|
name = "cdn-worker"
|
|
479
479
|
main = "src/index.ts"
|
|
480
|
-
compatibility_date = "
|
|
480
|
+
compatibility_date = "2026-01-01"
|
|
481
481
|
|
|
482
482
|
[[r2_buckets]]
|
|
483
483
|
binding = "ARTIFACTS"
|
|
@@ -587,17 +587,18 @@ const cdn = new CDN({
|
|
|
587
587
|
|
|
588
588
|
## Related Packages
|
|
589
589
|
|
|
590
|
-
- [@
|
|
591
|
-
- [@sygnl/identity-manager](https://www.npmjs.com/package/@
|
|
592
|
-
- [@sygnl/health-check](https://www.npmjs.com/package/@
|
|
590
|
+
- [@hammr/normalizer](https://www.npmjs.com/package/@hammr/normalizer) - PII normalization & SHA256 hashing (used internally)
|
|
591
|
+
- [@sygnl/identity-manager](https://www.npmjs.com/package/@traceos/identity-manager) - Session & identity tracking
|
|
592
|
+
- [@sygnl/health-check](https://www.npmjs.com/package/@traceos/health-check) - Production observability
|
|
593
|
+
- [@sygnl/event-schema](https://www.npmjs.com/package/@sygnl/event-schema) - Event schemas for e-commerce and SaaS
|
|
593
594
|
|
|
594
595
|
## License
|
|
595
596
|
|
|
596
|
-
|
|
597
|
+
Apache 2.0
|
|
597
598
|
|
|
598
599
|
## Contributing
|
|
599
600
|
|
|
600
|
-
Issues and PRs welcome! This package is part of the [
|
|
601
|
+
Issues and PRs welcome! This package is part of the [Hammr](https://hammr.ai) ecosystem.
|
|
601
602
|
|
|
602
603
|
---
|
|
603
604
|
|