Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/woozyking/deta-worker
Fetch API-based deta js library for browser and Service Worker environments
https://github.com/woozyking/deta-worker
Last synced: 3 days ago
JSON representation
Fetch API-based deta js library for browser and Service Worker environments
- Host: GitHub
- URL: https://github.com/woozyking/deta-worker
- Owner: woozyking
- License: mit
- Created: 2021-08-31T22:09:41.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-09T03:38:24.000Z (about 3 years ago)
- Last Synced: 2024-11-13T16:48:49.106Z (3 days ago)
- Language: JavaScript
- Size: 237 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deta - deta-worker - Fetch API-based deta js library for browser and Service Worker environments. (Misc's / Worker)
README
# deta-worker
Fetch API-based deta js library for browser and Service Worker environments.
This library fills the need to interact with Deta HTTP APIs in Cloudflare Workers, as the official [Deta JS SDK](https://github.com/deta/deta-javascript) at the moment is not working out-of-the-box with such a Service Worker environment.
API parity (vs. the official Deta JS SDK):
- [x] Base
- Drive
- [ ] `.put(name, options)`
- [ ] `.get(name)`
- [ ] `.delete(name)`
- [ ] `.deleteMany(names)`
- [ ] `.list(options)`_Note: this library works in Node.js with a monkey-patched global `fetch()` (such as through [node-fetch](https://github.com/node-fetch/node-fetch)), but why?_
## Usage
The high-level API usage patterns of this library aim to be nearly identical to the official SDK, so consult the respective [Base](https://docs.deta.sh/docs/base/sdk#using) and [Drive](https://docs.deta.sh/docs/drive/sdk#using) docs should suffice.
A few opinionated implementation details deviate from the official SDK (aside from the obvious styles). For instance, the `.util.trim()` method for Base `.updates()` is first-referenced as `.util.delete()` to best match the current [Base HTTP API documentation](https://docs.deta.sh/docs/base/http/#update-item) (also not to infringe the JS String `.trim()` method), but `.util.trim()` is still kept as an alias for drop-in compatibility.
## Installation
```shell
% npm i deta-worker
% # or
% yarn add deta-worker
```