File tree 3 files changed +38
-2
lines changed
3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -378,6 +378,42 @@ for await (const entry of store.list({ paginate: true })) {
378
378
console .log (blobs)
379
379
```
380
380
381
+ ## Server API reference
382
+
383
+ We provide a Node.js server that implements the Netlify Blobs server interface backed by the local filesystem. This is
384
+ useful if you want to write automated tests that involve the Netlify Blobs API without interacting with a live store.
385
+
386
+ The ` BlobsServer ` export lets you construct and initialize a server. You can then use its address to initialize a store.
387
+
388
+ ``` ts
389
+ import { BlobsServer , getStore } from ' @netlify/blobs'
390
+
391
+ // Choose any token for protecting your local server from
392
+ // extraneous requests
393
+ const token = ' some-token'
394
+
395
+ // Create a server by providing a local directory where all
396
+ // blobs and metadata should be persisted
397
+ const server = new BlobsServer ({
398
+ directory: ' /path/to/blobs/directory' ,
399
+ port: 1234 ,
400
+ token ,
401
+ })
402
+
403
+ await server .start ()
404
+
405
+ // Get a store and provide the address of the local server
406
+ const store = getStore ({
407
+ edgeURL: ' http://localhost:1234' ,
408
+ name: ' my-store' ,
409
+ token ,
410
+ })
411
+
412
+ await store .set (' my-key' , ' This is a local blob' )
413
+
414
+ console .log (await store .get (' my-key' ))
415
+ ```
416
+
381
417
## Contributing
382
418
383
419
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ const siteID = '9a003659-aaaa-0000-aaaa-63d3720d8621'
31
31
const storeName = 'mystore'
32
32
const apiToken = 'some token'
33
33
const edgeToken = 'some other token'
34
- const edgeURL = 'https://cloudfront.url '
34
+ const edgeURL = 'https://edge.netlify '
35
35
36
36
describe ( 'list' , ( ) => {
37
37
describe ( 'With API credentials' , ( ) => {
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ const value = 'some value'
38
38
const apiToken = 'some token'
39
39
const signedURL = 'https://signed.url/123456789'
40
40
const edgeToken = 'some other token'
41
- const edgeURL = 'https://cloudfront.url '
41
+ const edgeURL = 'https://edge.netlify '
42
42
43
43
describe ( 'get' , ( ) => {
44
44
describe ( 'With API credentials' , ( ) => {
You can’t perform that action at this time.
0 commit comments