All Projects → losfair → blueboat

losfair / blueboat

Licence: Apache-2.0 license
All-in-one, multi-tenant serverless JavaScript runtime.

Programming Languages

rust
11053 projects
typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to blueboat

vite-node
Vite as Node.js runtime
Stars: ✭ 422 (-76.97%)
Mutual labels:  runtime
DotNetJS
Consume C# in JavaScript with comfort: single-file UMD library, auto-generated 2-way bindings and type definitions
Stars: ✭ 551 (-69.92%)
Mutual labels:  runtime
Runtime-Headers
💿 iOS, macOS runtime headers
Stars: ✭ 26 (-98.58%)
Mutual labels:  runtime
oasis-sdk
Official SDK for the Oasis Network.
Stars: ✭ 57 (-96.89%)
Mutual labels:  runtime
tesseract-ocr-re
Tesseract 4 OCR Runtime Environment - Docker Container
Stars: ✭ 94 (-94.87%)
Mutual labels:  runtime
cache
Simple and easy go cache micro framework
Stars: ✭ 12 (-99.34%)
Mutual labels:  runtime
orion
Elegant tweak development in pure Swift
Stars: ✭ 149 (-91.87%)
Mutual labels:  runtime
RuntimeBPs
This project allows for visual scripting in UE4 similar to Blueprints, but at runtime. The way this is set up does not make use of any UE4 boilerplate and could with a few adjustments be used in another engine.
Stars: ✭ 77 (-95.8%)
Mutual labels:  runtime
subwasm
Subwasm is a cli utility to help you know more about WASM Runtimes. It help downloading, inspecting and comparing Substrate based chains such as Polkadot or Kusama.
Stars: ✭ 53 (-97.11%)
Mutual labels:  runtime
vim-venom
Select Python runtimes or activate virtual-environments while working in Neo/Vim.
Stars: ✭ 33 (-98.2%)
Mutual labels:  runtime
golden
a benchmark for compile-time and/or runtime Nim 🏆
Stars: ✭ 28 (-98.47%)
Mutual labels:  runtime
AROS
www.axrt.org
Stars: ✭ 33 (-98.2%)
Mutual labels:  runtime
runtime-snaps
Core repository for Solus runtime snaps
Stars: ✭ 32 (-98.25%)
Mutual labels:  runtime
mkBox
MacApp、PythonPackage、Scripts ..
Stars: ✭ 66 (-96.4%)
Mutual labels:  runtime
UnityNativeTool
Allows to unload native plugins in Unity3d editor
Stars: ✭ 147 (-91.98%)
Mutual labels:  runtime
webpack-extract-translation-keys
This plugin extracts translation keys for applications requiring runtime translations
Stars: ✭ 35 (-98.09%)
Mutual labels:  runtime
vercel-bref
▲ Vercel bref runtime • brefphp • vercel-bref
Stars: ✭ 25 (-98.64%)
Mutual labels:  runtime
quickjs-build
Build for QuickJS JavaScript Engine
Stars: ✭ 25 (-98.64%)
Mutual labels:  runtime
node-mini
Mini Node.js runtime built on V8
Stars: ✭ 24 (-98.69%)
Mutual labels:  runtime
runtime-config-loader
This is an Angular library that provides an easy way to load a configuration JSON file for runtime configuration.
Stars: ✭ 32 (-98.25%)
Mutual labels:  runtime

Blueboat

CI

Blueboat is an all-in-one, multi-tenant serverless JavaScript runtime. See the site for a brief introduction on features.

A simple Blueboat application looks like:

Router.get("/", req => new Response("hello world"));

Router.get("/example", req => {
  return fetch("https://example.com");
});

Router.get("/yaml", req => {
  const res = TextUtil.Yaml.stringify({
    hello: "world",
  });
  return new Response(res);
});

Quickstart (single-tenant mode)

This pulls, builds, and runs the hello-world example.

Prerequisites: cargo, npm, git, docker

cargo install boatctl
git clone https://github.com/losfair/blueboat-examples
cd blueboat-examples/hello-world
npm i && boat pack -o build.json
docker run --rm -d -p 127.0.0.1:3001:3001 \
  -v "$PWD:/app" \
  --entrypoint /usr/bin/blueboat_server \
  -e RUST_LOG=info \
  -e SMRAPP_BLUEBOAT_DISABLE_SECCOMP=1 \
  ghcr.io/losfair/blueboat:v0.3.1-alpha.5 \
  -l "0.0.0.0:3001" \
  --single-tenant "/app/build.json"
curl http://localhost:3001 # "hello world"

The JavaScript API

Web API compatibility

Blueboat prefers to keep compatibility with the Web API when doing so is reasonable.

  • Things like fetch, Request, Response and URL are built-in.

No local resources

Blueboat is a “distributed-system-native” runtime and prioritizes frictionless scalability over single-node performance. Local resources are abstracted out and replaced with their equivalents in a distributed system:

  • Files → Key-value store
  • Sockets → Event stream
  • Single-file databases → Key-value store, App.mysql and App.postgresql object families
  • FFI → WebAssembly

Read and write files

// Don't: The filesystem is a local resource
import { writeFileSync } from "fs"
writeFileSync("hello.txt", "Hello from Node")

// Do: Use the key-value store
const ns = new KV.Namespace("files")
await ns.set("hello.txt", "Hello from Blueboat")

Stream data to client

// Don't: Sockets are a local resource
import { WebSocketServer } from "ws";
const wss = new WebSocketServer({ port: 8080 });
wss.on("connection", (ws) => {
  ws.on("message", (data) => {
    console.log("received: %s", data);
  });
  ws.send("something");
});

// Do: Use the PubSub API
Router.post("/send_to_group", async req => {
  const { groupId, message } = await req.json();
  await App.pubsub.myChannel.publish(groupId, message)
  return new Response("ok");
});

Use SQL databases

// Don't: SQLite databases are stored on the local filesystem
import { DB } from "https://deno.land/x/sqlite/mod.ts";
const db = new DB("test.db");
const people = db.query("SELECT name FROM people");

// Do: Use `App.mysql` or `App.postgresql`
const people = App.mysql.myDatabase.exec("SELECT name FROM people", {}, "s");

Developing on Blueboat

You can use your favorite JS/TS bundler to build your project for Blueboat. webpack works, and other bundlers like esbuild and bun should work too.

You can package and run your apps with single-tenant mode as described in the Quickstart section, or deploy it on a multi-tenant service like MagicBoat.

TypeScript type definitions

Pull in the blueboat-types package in your TypeScript project, and add it to your tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "blueboat-types"
    ]
  }
}

API documentation

While there isn't a lot of documentation on Blueboat's API yet, the global object declared in jsland can be seen as the source-of-truth of the public API.

Meanwhile, refer to the tracking issue for a high-level overview of the API.

Deploying Blueboat

There are two options for deploying Blueboat apps.

Single-tenant

This mode works well for local development and private self-hosting. The steps are described in quickstart.

Multi-tenant

This is a fully optimized mode for multi-tenant operation. See the guide to deploy a multi-tenant environment yourself, or request access to our hosted environment, MagicBoat.

Frameworks

Simple web backends with JSON API and template-based rendering can be built without requiring any third-party frameworks. If you have more complex needs like server-side rendering React or just prefer a different style of router API, third-party frameworks are also available.

Flareact

Flareact is an edge-rendered React framework built for Cloudflare Workers. Since Blueboat and Workers both implement a large (and mostly overlapping) subset of the Web API, Flareact also works on Blueboat with some modifications in the entry script.

See the source code of my blog as an example of using Flareact with Blueboat.

Contributing

Build locally

Clone the repository, and run ./build.sh.

Build process internals

Normally the build process is handled automatically by build.sh. Here are some internals, in case you need it.

Blueboat is built in three stages: jsland build, rust prebuild and rust final build. The jsland build stage bundles /jsland/; the rust prebuild stage generates a blueboat_mkimage binary that is used to generate JSLAND_SNAPSHOT from /jsland/; and the rust final build stage generates the final blueboat_server binary.

Please refer to the CI script for a reproducible set of steps.

License

Apache-2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].