Skip to content

Commit 4bb33bf

Browse files
committed
chore: add BlobsServer to README
1 parent 84e4e58 commit 4bb33bf

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,42 @@ for await (const entry of store.list({ paginate: true })) {
378378
console.log(blobs)
379379
```
380380

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+
381417
## Contributing
382418

383419
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or

src/list.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const siteID = '9a003659-aaaa-0000-aaaa-63d3720d8621'
3131
const storeName = 'mystore'
3232
const apiToken = 'some token'
3333
const edgeToken = 'some other token'
34-
const edgeURL = 'https://cloudfront.url'
34+
const edgeURL = 'https://edge.netlify'
3535

3636
describe('list', () => {
3737
describe('With API credentials', () => {

src/main.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const value = 'some value'
3838
const apiToken = 'some token'
3939
const signedURL = 'https://signed.url/123456789'
4040
const edgeToken = 'some other token'
41-
const edgeURL = 'https://cloudfront.url'
41+
const edgeURL = 'https://edge.netlify'
4242

4343
describe('get', () => {
4444
describe('With API credentials', () => {

0 commit comments

Comments
 (0)