Commit 78348e4
authored
feat: Remaining KV Functions, File-System KV Store, Cache API Stubs, Workers Sites Support (#57)
* feat(KVNamespace): bring kv implementation more in line with docs
This commit adds value types to get and put, the getWithMetadata and list functions, and returns null if a key could not be found. This brings the KV implementation more in line with the documentation here: https://developers.cloudflare.com/workers/runtime-apis/kv. The only things missing now are ReadableStream & FormData support, and potentially errors when data is too large.
* test(KVNamespace): add tests for new kv implementation
* fix(start): empty string kv namespace added to context
* feat(FileKVStore): add file system backed kv store
This commit adds an implementation of a KV store that uses the file system to store data. This is required for Workers Sites, but is also a simpler way (compared to Minio) of persisting local KV data between restarts.
* test(FileKVStore): add tests for file system backed kv store
* feat(caches): add caches api stubs to worker context
Workers Sites required the caches API to be in scope, but they don't actually need to cache any data to function. So this commit stubs out the API and puts it in the worker context.
* feat(Workers Sites): add Workers Sites support
If the passed wrangler.toml file has a [site] section with a bucket field, the __STATIC_CONTENT KV namespace and __STATIC_CONTENT_MANIFEST object will be injected into the worker context, allowing the Worker Site to be served.
* feat(FileKVStore): enable file system backed kv store by env
This allows the file system backed KV store to be used for all KV namespaces, not just for Workers Sites. Setting the "KV_FILE_ROOT" environment variable enables this. For namespace "NAMESPACE", files will be stored in "KV_FILE_ROOT/NAMESPACE". Values will be stored in files named the same as their key. Metadata and expiration information (if provided) is stored in a .meta.json file prefixed with the key.
* docs(README): add file system kv store and workers sites to README
* docs(README): add note add importing kv asset handler1 parent ce60044 commit 78348e4
File tree
12 files changed
+1302
-34
lines changed- app
- __tests__
12 files changed
+1302
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
| |||
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
0 commit comments