Munk Runner

Munk is a Functions-as-a-Service (FaaS) runtime written in Rust. It lets you run your JavaScript, TypeScript, and WebAssembly scripts on the edge or locally. Use it for edge functions, A/B testing, security features, or anything else you can create.

Example Function

Define a serverless function in a few lines. Munk handles the rest:

Munk.serve(async (req) => {
    const res = await fetch('https://jsonplaceholder.typicode.com/todos/1');
    const data = await res.json();

    return new Response(JSON.stringify({ data }))
})

Setup

Pull the container image and configure with environment variables:

docker pull ghcr.io/edum22/munk-runner:<VERSION>
Variable Description Default
MUNK_DB_PATH Custom save path for the database /var/lib/munk/
MUNK_ENCRYPTION_KEY Encryption key for the database
MUNK_AUTH_HEADER_VALUE Admin auth header value
MUNK_LOG_TOKEN Auth token for viewing logs MUNK_AUTH_HEADER_VALUE
MUNK_USE_SESSION Use MunkSession for persistent execution false
MUNK_TELEMETRY Enable/disable telemetry true

Runtime Info

The runtime conforms to the WinterTC spec. The navigator.userAgent value is Munk.

Using MUNK_USE_SESSION can increase throughput by caching the v8/deno_core runtime per function. If you need every request to use a clean deno_core isolate, do not enable it.

Limits

Code execution has a default timeout of 15 seconds and a CPU limit of 50ms. These can be configured when creating the function.

Users without a license are limited to 5 functions.

Custom API

Munk.env.get(key: string) -> string | undefined | null
Munk.env.toObject() -> { key: value } | undefined | null

Munk.serve((req: Request) => Response | Promise<Response>)

Upload CLI

Use hilly to upload code to Munk more easily.