Skip to content

openworkers/openworkers-runtime-quickjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenWorkers Runtime QuickJS

Lightweight JavaScript runtime for serverless workers, built on QuickJS.

Quick Start

use openworkers_runtime_quickjs::{Worker, Script, Event, HttpRequest, HttpMethod, RequestBody};
use std::collections::HashMap;

let script = Script::new(r#"
    addEventListener('fetch', event => {
        event.respondWith(new Response('Hello from QuickJS!'));
    });
"#);

let mut worker = Worker::new(script, None).await?;

let req = HttpRequest {
    method: HttpMethod::Get,
    url: "http://localhost/".to_string(),
    headers: HashMap::new(),
    body: RequestBody::None,
};

let (task, rx) = Event::fetch(req);
worker.exec(task).await?;

let response = rx.await?;

Features

  • Lightweight — Small binary footprint (~200KB)
  • Fast cold start — Sub-millisecond worker creation
  • Web APIs — fetch, setTimeout, Response, Request, URL, console
  • Async/await — Full Promise support
  • Streaming — ReadableStream support

Testing

cargo test

Status

See TODO.md for current limitations and roadmap.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages