Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanarus/night_worker
https://github.com/kanarus/night_worker
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kanarus/night_worker
- Owner: kanarus
- Created: 2024-04-28T18:44:54.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-04-29T11:26:39.000Z (7 months ago)
- Last Synced: 2024-10-07T04:19:09.808Z (about 1 month ago)
- Language: Rust
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
night_worker
Ergonimic Cloudflare Workers SDK for nightly Rust
- For [fetch](https://developers.cloudflare.com/workers/runtime-apis/handlers/fetch/) use mainly
- Built upon [workers-rs](https://crates.io/crates/worker)
## Supported Bindings
- [x] KV
- [x] Service Bindings
- [x] D1 ( by `"d1"` feature )
- [x] Queues ( by `"queue"` feature )
- [ ] Durable Objects ( TODO )
## Example
*Cargo.toml*
```toml
# The same version of
# `worker` crate will be supported[dependencies]
worker = "0.1.0"
night_worker = "0.1.0-rc"
```*src/lib.rs*
```rust
use worker::{Request, Env, Context, Result, Response};
use night_worker::Worker;#[worker::event(fetch)]
async fn main(
req: Request,
env: Env,
ctx: Context,
) -> Result {
let w = Worker::take_over(env, ctx);
let kv = w.KV("MY_KV")?;kv.put("key1", "value1").await?;
kv.put("key2", "value2").expiration_ttl(1024).await?;let value = kv.get("key1").await?;
let value = kv.get("key2").cache_ttl(1024).await?;let all = kv.list().await?;
let all = kv.list().prefix("pref").limit(42).await?;todo!()
}
```