Skip to content

Commit 03150e1

Browse files
committed
Abstract out Storage Provider
1 parent e35b8c1 commit 03150e1

30 files changed

+1408
-1023
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const config = {
159159
includeWellKnown: true,
160160

161161
// Advanced filtering (optional):
162-
kvStoreAssetInclusionTest: (key, contentType) => {
162+
assetInclusionTest: (key, contentType) => {
163163
return true; // include everything by default
164164
},
165165

@@ -194,7 +194,7 @@ You can override this file for a single `publish-content` command by specifying
194194
- `excludeDirs` - Array of directory names or regex patterns to exclude (default: `['./node_modules']`).
195195
- `excludeDotFiles` - Exclude dotfiles and dot-named directories (default: true).
196196
- `includeWellKnown` - Always include `.well-known` even if dotfiles are excluded (default: true).
197-
- `kvStoreAssetInclusionTest` - Function to determine inclusion and variant behavior per file.
197+
- `assetInclusionTest` - Function to determine inclusion and variant behavior per file.
198198
- `contentCompression` - Array of compression formats to pre-generate (`['br', 'gzip']` by default).
199199
- `contentTypes` - Additional or override content type definitions.
200200

@@ -483,7 +483,7 @@ async function handleRequest(request) {
483483
484484
## 📥 Using Published Assets in Your Code
485485
486-
To access files you've published, use the `getMatchingAsset()` and `loadKvAssetVariant()` methods on `publisherServer`.
486+
To access files you've published, use the `getMatchingAsset()` and `loadAssetVariant()` methods on `publisherServer`.
487487

488488
### Access Metadata for a File:
489489

@@ -502,16 +502,16 @@ if (asset != null) {
502502
### Load the File from KV Store:
503503

504504
```js
505-
const kvAssetVariant = await publisherServer.loadKvAssetVariant(asset, null); // pass 'gzip' or 'br' for compressed
505+
const assetVariant = await publisherServer.loadAssetVariant(asset, null); // pass 'gzip' or 'br' for compressed
506506
507-
kvAssetVariant.kvStoreEntry; // KV Store entry (type KVStoreEntry defined in 'fastly:kv-store')
508-
kvAssetVariant.size; // Size of the variant
509-
kvAssetVariant.hash; // SHA256 of the variant
510-
kvAssetVariant.contentEncoding; // 'gzip', 'br', or null
511-
kvAssetVariant.numChunks; // Number of chunks (for large files)
507+
assetVariant.storageEntry; // Storage entry (type StorageEntry defined in './src/storage/storage-provider.ts')
508+
assetVariant.size; // Size of the variant
509+
assetVariant.hash; // SHA256 of the variant
510+
assetVariant.contentEncoding; // 'gzip', 'br', or null
511+
assetVariant.numChunks; // Number of chunks (for large files)
512512
```
513513

514-
You can stream `kvAssetVariant.kvStoreEntry.body` directly to a `Response`, or read it using `.text()`, `.json()`, or `.arrayBuffer()` depending on its content type.
514+
You can stream `assetVariant.storageEntry.body` directly to a `Response`, or read it using `.text()`, `.json()`, or `.arrayBuffer()` depending on its content type.
515515

516516
---
517517

@@ -609,7 +609,7 @@ After this process is complete, the PublisherServer object in the Compute applic
609609
610610
*At most one of **`--expires-in`**, **`--expires-at`**, or **`--expires-never`** may be specified*
611611
612-
**Global Options:**
612+
**KV Store Options:**
613613
614614
- `--local`: Instead of working with the Fastly KV Store, operate on local files that will be used to simulate the KV Store with the local development environment.
615615
@@ -633,7 +633,7 @@ This can include expired collection indexes and orphaned content assets.
633633
- `--delete-expired-collections`: If set, expired collection index files will be deleted.
634634
- `--dry-run`: Show what would be deleted without performing any deletions.
635635
636-
**Global Options:**
636+
**KV Store Options:**
637637
638638
- `--local`: Instead of working with the Fastly KV Store, operate on local files that will be used to simulate the KV Store with the local development environment.
639639
@@ -650,7 +650,7 @@ Lists all collections currently published in the KV Store.
650650
651651
##### Options:
652652
653-
**Global Options:**
653+
**KV Store Options:**
654654
655655
- `--local`: Instead of working with the Fastly KV Store, operate on local files that will be used to simulate the KV Store with the local development environment.
656656
@@ -681,7 +681,7 @@ Copies an existing collection (content + config) to a new collection name.
681681
682682
*At most one of **`--expires-in`**, **`--expires-at`**, or **`--expires-never`** may be specified*. If not provided, then the existing expiration rule of the collection being promoted is used.
683683
684-
**Global Options:**
684+
**KV Store Options:**
685685
686686
- `--local`: Instead of working with the Fastly KV Store, operate on local files that will be used to simulate the KV Store with the local development environment.
687687
@@ -709,7 +709,7 @@ Sets or updates the expiration time of an existing collection.
709709
710710
*Exactly one of **`--expires-in`**, **`--expires-at`**, or **`--expires-never`** must be specified*
711711
712-
**Global Options:**
712+
**KV Store Options:**
713713
714714
- `--local`: Instead of working with the Fastly KV Store, operate on local files that will be used to simulate the KV Store with the local development environment.
715715
@@ -732,7 +732,7 @@ Use the `npx @fastly/compute-js-static-publish clean` command afterward to remov
732732
733733
- `--collection-name`: The name of the collection to delete (required)
734734
735-
**Global Options:**
735+
**KV Store Options:**
736736
737737
- `--local`: Instead of working with the Fastly KV Store, operate on local files that will be used to simulate the KV Store with the local development environment.
738738

0 commit comments

Comments
 (0)