-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime-apis.html
More file actions
31 lines (29 loc) · 41.7 KB
/
Copy pathruntime-apis.html
File metadata and controls
31 lines (29 loc) · 41.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Runtime APIs | Lagoss</title>
<meta name="description" content="An open-source runtime and platform that allows developers to run TypeScript and JavaScript Serverless Functions.">
<meta name="generator" content="VitePress v1.0.0-rc.44">
<link rel="preload stylesheet" href="/assets/style.Dl058EZ5.css" as="style">
<script type="module" src="/assets/app.yn0IZKkT.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Bu8hRsVA.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/framework.CSd21wiM.js">
<link rel="modulepreload" href="/assets/chunks/theme.DanHaxrE.js">
<link rel="modulepreload" href="/assets/runtime-apis.md.jbG-txpu.lean.js">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar has-sidebar" data-v-ae24b3ad data-v-19c990f1><div class="wrapper" data-v-19c990f1><div class="container" data-v-19c990f1><div class="title" data-v-19c990f1><div class="VPNavBarTitle has-sidebar" data-v-19c990f1 data-v-ab179fa1><a class="title" href="/" data-v-ab179fa1><!--[--><!--]--><!--[--><img class="VPImage logo" src="/icon-white.png" alt data-v-8426fc1a><!--]--><span data-v-ab179fa1>Lagoss</span><!--[--><!--]--></a></div></div><div class="content" data-v-19c990f1><div class="content-body" data-v-19c990f1><!--[--><!--]--><div class="VPNavBarSearch search" data-v-19c990f1><!----></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-19c990f1 data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/" tabindex="0" data-v-7f418b0f data-v-42ef59de><!--[--><span data-v-42ef59de>Home</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/introduction.html" tabindex="0" data-v-7f418b0f data-v-42ef59de><!--[--><span data-v-42ef59de>Docs</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-19c990f1 data-v-e6aabb21><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-e6aabb21 data-v-d1f28634 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-d1f28634></span><span class="vpi-moon moon" data-v-d1f28634></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-19c990f1 data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/lagossapp/lagoss" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><span class="vpi-social-github" /></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-19c990f1 data-v-d0bd9dde data-v-b6c34ac9><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-b6c34ac9><span class="vpi-more-horizontal icon" data-v-b6c34ac9></span></button><div class="menu" data-v-b6c34ac9><div class="VPMenu" data-v-b6c34ac9 data-v-e7ea1737><!----><!--[--><!--[--><!----><div class="group" data-v-d0bd9dde><div class="item appearance" data-v-d0bd9dde><p class="label" data-v-d0bd9dde>Appearance</p><div class="appearance-action" data-v-d0bd9dde><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-d0bd9dde data-v-d1f28634 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-d1f28634></span><span class="vpi-moon moon" data-v-d1f28634></span><!--]--></span></span></button></div></div></div><div class="group" data-v-d0bd9dde><div class="item social-links" data-v-d0bd9dde><div class="VPSocialLinks social-links-list" data-v-d0bd9dde data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/lagossapp/lagoss" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><span class="vpi-social-github" /></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-19c990f1 data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><div class="divider" data-v-19c990f1><div class="divider-line" data-v-19c990f1></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-5d98c3a5 data-v-a6f0e41e><div class="container" data-v-a6f0e41e><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-a6f0e41e><span class="vpi-align-left menu-icon" data-v-a6f0e41e></span><span class="menu-text" data-v-a6f0e41e>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-a6f0e41e data-v-d2ecc192><button data-v-d2ecc192>Return to top</button><!----></div></div></div><aside class="VPSidebar" data-v-5d98c3a5 data-v-575e6a36><div class="curtain" data-v-575e6a36></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-575e6a36><span class="visually-hidden" id="sidebar-aria-label" data-v-575e6a36> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="group" data-v-575e6a36><section class="VPSidebarItem level-0 has-active" data-v-575e6a36 data-v-93e7e794><!----><div class="items" data-v-93e7e794><!--[--><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/introduction.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Introduction</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/getting-started.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Getting Started</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/runtime-apis.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Runtime APIs</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/cli.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>CLI</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/examples.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Examples</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-575e6a36><section class="VPSidebarItem level-0 collapsible" data-v-575e6a36 data-v-93e7e794><div class="item" role="button" tabindex="0" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><h2 class="text" data-v-93e7e794>Usage</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-93e7e794><span class="vpi-chevron-right caret-icon" data-v-93e7e794></span></div></div><div class="items" data-v-93e7e794><!--[--><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/usage/deployments.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Deployments</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/usage/assets.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Assets</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/usage/environment-variables.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Environment variables</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/usage/domains.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Domains</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/usage/logs.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Logs</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/usage/cron.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Cron</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/usage/limits.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Limits</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/usage/security.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Security</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-575e6a36><section class="VPSidebarItem level-0 collapsible collapsed" data-v-575e6a36 data-v-93e7e794><div class="item" role="button" tabindex="0" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><h2 class="text" data-v-93e7e794>Self hosting</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-93e7e794><span class="vpi-chevron-right caret-icon" data-v-93e7e794></span></div></div><div class="items" data-v-93e7e794><!--[--><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/self-hosting/installation.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Installation</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-93e7e794 data-v-93e7e794><div class="item" data-v-93e7e794><div class="indicator" data-v-93e7e794></div><a class="VPLink link link" href="/self-hosting/configuration.html" data-v-93e7e794><!--[--><p class="text" data-v-93e7e794>Configuration</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-5d98c3a5 data-v-1428d186><div class="VPDoc has-sidebar has-aside" data-v-1428d186 data-v-39a288b8><!--[--><!--]--><div class="container" data-v-39a288b8><div class="aside" data-v-39a288b8><div class="aside-curtain" data-v-39a288b8></div><div class="aside-container" data-v-39a288b8><div class="aside-content" data-v-39a288b8><div class="VPDocAside" data-v-39a288b8 data-v-3f215769><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline" role="navigation" data-v-3f215769 data-v-935f8a84><div class="content" data-v-935f8a84><div class="outline-marker" data-v-935f8a84></div><div class="outline-title" role="heading" aria-level="2" data-v-935f8a84>On this page</div><nav aria-labelledby="doc-outline-aria-label" data-v-935f8a84><span class="visually-hidden" id="doc-outline-aria-label" data-v-935f8a84> Table of Contents for current page </span><ul class="VPDocOutlineItem root" data-v-935f8a84 data-v-b933a997><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-39a288b8><div class="content-container" data-v-39a288b8><!--[--><!--]--><main class="main" data-v-39a288b8><div style="position:relative;" class="vp-doc _runtime-apis" data-v-39a288b8><div><h1 id="runtime-apis" tabindex="-1">Runtime APIs <a class="header-anchor" href="#runtime-apis" aria-label="Permalink to "Runtime APIs""></a></h1><p>The following APIs are the same as the native Web APIS you already know. We also follow the <a href="https://wintercg.org/" target="_blank" rel="noreferrer">WinterCG</a> conventions. Lagoss's Runtime uses the V8 engine and is written in both Rust and TypeScript.</p><h2 id="handler" tabindex="-1">Handler <a class="header-anchor" href="#handler" aria-label="Permalink to "Handler""></a></h2><p>The only required code to make your Function runnable is to export a <code>handler</code> function, that accepts a <a href="#request"><code>Request</code></a> and returns a <a href="#response"><code>Response</code></a> (or a promise returning a Response):</p><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> function</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> handler</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">request</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> Request</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> new</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> Response</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Hello World!'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>Starting from this simple code, you can do whatever you wish, using the Web APIs you already know.</p><h2 id="additional-headers" tabindex="-1">Additional Headers <a class="header-anchor" href="#additional-headers" aria-label="Permalink to "Additional Headers""></a></h2><p>The <code>Request</code> object coming from the <code>handler</code> function also contains additional headers:</p><ul><li><code>X-Lagon-Region</code>: the <a href="./usage/regions.html">region</a> where this Function is executing</li><li><code>X-Forwarded-For</code>: the IP address of the client that made the request</li></ul><p>You can access them the same as any other header:</p><div class="language-typescript vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">typescript</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> function</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> handler</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">request</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> Request</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>
<span class="line highlighted"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> region</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> request.headers.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">get</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'x-lagon-region'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
<span class="line highlighted"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> ip</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> request.headers.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">get</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'x-forwarded-for'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> new</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> Response</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">`Region: ${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">region</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}, User IP: ${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}`</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>The <code>X-Lagon-Region</code> header is also automatically added to each response, making it easy to identify which Region served the request.</p><div class="info custom-block"><p class="custom-block-title">INFO</p><p>When developing locally using <a href="./cli.html#lagoss-dev"><code>lagoss dev</code></a>, the <code>X-Lagon-Region</code> header will be set to <code>local</code>.</p></div><h2 id="npm-support" tabindex="-1">NPM support <a class="header-anchor" href="#npm-support" aria-label="Permalink to "NPM support""></a></h2><p>Lagoss's Runtime supports any NPM package. The only requirement is that the package must not use Node.js-specific APIs (e.g <code>Buffer</code>, <code>fs</code>, <code>path</code>, etc.). This is because Lagoss's Runtime <strong>is not Node.js</strong>, but a browser-like environment.</p><h2 id="global-objects" tabindex="-1">Global objects <a class="header-anchor" href="#global-objects" aria-label="Permalink to "Global objects""></a></h2><h3 id="abortcontroller" tabindex="-1"><code>AbortController</code> <a class="header-anchor" href="#abortcontroller" aria-label="Permalink to "`AbortController`""></a></h3><p>The standard <code>AbortController</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/AbortController" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="abortsignal" tabindex="-1"><code>AbortSignal</code> <a class="header-anchor" href="#abortsignal" aria-label="Permalink to "`AbortSignal`""></a></h3><p>The standard <code>AbortSignal</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="asynccontext" tabindex="-1"><code>AsyncContext</code> <a class="header-anchor" href="#asynccontext" aria-label="Permalink to "`AsyncContext`""></a></h3><p>An early implementation of the <a href="https://github.com/tc39/proposal-async-context" target="_blank" rel="noreferrer">Async Context proposal</a>. You shouldn't use this API yet, as it is still experimental and subject to change.</p><h3 id="asynclocalstorage" tabindex="-1"><code>AsyncLocalStorage</code> <a class="header-anchor" href="#asynclocalstorage" aria-label="Permalink to "`AsyncLocalStorage`""></a></h3><p>A minimal implementation of <a href="https://nodejs.org/api/async_context.html#class-asynclocalstorage" target="_blank" rel="noreferrer">Node.js's AsyncLocalStorage</a>. The following methods are supported:</p><ul><li><code>getStore()</code></li><li><code>run(store, callback, ...args)</code></li></ul><h3 id="blob" tabindex="-1"><code>Blob</code> <a class="header-anchor" href="#blob" aria-label="Permalink to "`Blob`""></a></h3><p>The standard <code>Blob</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="compression-stream-apis" tabindex="-1">Compression Stream APIs <a class="header-anchor" href="#compression-stream-apis" aria-label="Permalink to "Compression Stream APIs""></a></h3><p>Lagoss supports all three compression formats: <code>gzip</code>, <code>deflate</code> and <code>deflate-raw</code>.</p><h4 id="compressionstream" tabindex="-1"><code>CompressionStream</code> <a class="header-anchor" href="#compressionstream" aria-label="Permalink to "`CompressionStream`""></a></h4><p>The standard <code>CompressionStream</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h4 id="decompressionstream" tabindex="-1"><code>DecompressionStream</code> <a class="header-anchor" href="#decompressionstream" aria-label="Permalink to "`DecompressionStream`""></a></h4><p>The standard <code>DecompressionStream</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="console" tabindex="-1"><code>console</code> <a class="header-anchor" href="#console" aria-label="Permalink to "`console`""></a></h3><p>Similar to the standard <code>console</code> object on the browser and Node.js, except that it only supports the following methods:</p><ul><li><code>log</code></li><li><code>info</code></li><li><code>debug</code></li><li><code>warn</code></li><li><code>error</code></li></ul><p>You can log multiple objects, and use string substitution. <a href="https://developer.mozilla.org/en-US/docs/Web/API/console#outputting_text_to_the_console" target="_blank" rel="noreferrer">See the documentation on MDN</a>. See the <a href="./usage/logs.html">Logs</a> documentation to learn more.</p><h3 id="crypto" tabindex="-1"><code>crypto</code> <a class="header-anchor" href="#crypto" aria-label="Permalink to "`crypto`""></a></h3><p>The standard <code>crypto</code> object.</p><h4 id="crypto-randomuuid" tabindex="-1"><code>crypto.randomUUID()</code> <a class="header-anchor" href="#crypto-randomuuid" aria-label="Permalink to "`crypto.randomUUID()`""></a></h4><p>The standard <code>randomUUID()</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h4 id="crypto-getrandomvalues" tabindex="-1"><code>crypto.getRandomValues()</code> <a class="header-anchor" href="#crypto-getrandomvalues" aria-label="Permalink to "`crypto.getRandomValues()`""></a></h4><p>The standard <code>getRandomValues()</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h4 id="crypto-subtle" tabindex="-1"><code>crypto.subtle</code> <a class="header-anchor" href="#crypto-subtle" aria-label="Permalink to "`crypto.subtle`""></a></h4><p>The standard <code>CryptoSubtle</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><div class="info custom-block"><p class="custom-block-title">INFO</p><p>The following table summarizes the supported algorithms on each method:</p><table><thead><tr><th></th><th><code>sign()</code>, <code>verify()</code></th><th><code>encrypt()</code>, <code>decrypt()</code></th><th><code>digest()</code></th><th><code>deriveBits()</code>, <code>deriveKey()</code></th><th><code>wrapKey()</code>, <code>unwrapKey()</code></th></tr></thead><tbody><tr><td>RSASSA-PKCS1-v1_5</td><td>✅</td><td></td><td></td><td></td><td></td></tr><tr><td>RSA-PSS</td><td>✅</td><td></td><td></td><td></td><td></td></tr><tr><td>ECDSA</td><td>✅</td><td></td><td></td><td></td><td></td></tr><tr><td>HMAC</td><td>✅</td><td></td><td></td><td></td><td></td></tr><tr><td>RSA-OAEP</td><td></td><td>✅</td><td></td><td></td><td>✅</td></tr><tr><td>AES-CTR</td><td></td><td>✅</td><td></td><td></td><td>✅</td></tr><tr><td>AES-CBC</td><td></td><td>✅</td><td></td><td></td><td>✅</td></tr><tr><td>AES-GCM</td><td></td><td>✅</td><td></td><td></td><td>✅</td></tr><tr><td>SHA-1</td><td></td><td></td><td>✅</td><td></td><td></td></tr><tr><td>SHA-256</td><td></td><td></td><td>✅</td><td></td><td></td></tr><tr><td>SHA-384</td><td></td><td></td><td>✅</td><td></td><td></td></tr><tr><td>SHA-512</td><td></td><td></td><td>✅</td><td></td><td></td></tr><tr><td>ECDH</td><td></td><td></td><td></td><td>✅</td><td></td></tr><tr><td>HKDF</td><td></td><td></td><td></td><td>✅</td><td></td></tr><tr><td>PBKDF2</td><td></td><td></td><td></td><td>✅</td><td></td></tr><tr><td>AES-KW</td><td></td><td></td><td></td><td></td><td>❌</td></tr></tbody></table></div><h3 id="customevent" tabindex="-1"><code>CustomEvent</code> <a class="header-anchor" href="#customevent" aria-label="Permalink to "`CustomEvent`""></a></h3><p>The standard <code>CustomEvent</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="event" tabindex="-1"><code>Event</code> <a class="header-anchor" href="#event" aria-label="Permalink to "`Event`""></a></h3><p>The standard <code>Event</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/Event" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="eventtarget" tabindex="-1"><code>EventTarget</code> <a class="header-anchor" href="#eventtarget" aria-label="Permalink to "`EventTarget`""></a></h3><p>The standard <code>EventTarget</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="fetch-apis" tabindex="-1">Fetch APIs <a class="header-anchor" href="#fetch-apis" aria-label="Permalink to "Fetch APIs""></a></h3><div class="info custom-block"><p class="custom-block-title">INFO</p><p>Looking for the <code>fetch()</code> method? <a href="#fetch">Jump to fetch()</a>.</p></div><h4 id="headers" tabindex="-1"><code>Headers</code> <a class="header-anchor" href="#headers" aria-label="Permalink to "`Headers`""></a></h4><p>The standard <code>Headers</code> object. It also supports the <a href="https://fetch.spec.whatwg.org/#dom-headers-getsetcookie" target="_blank" rel="noreferrer"><code>getSetCookie()</code> method</a>. <a href="https://developer.mozilla.org/en-US/docs/Web/API/Headers" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h4 id="request" tabindex="-1"><code>Request</code> <a class="header-anchor" href="#request" aria-label="Permalink to "`Request`""></a></h4><p>The standard <code>Request</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/Request" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h4 id="response" tabindex="-1"><code>Response</code> <a class="header-anchor" href="#response" aria-label="Permalink to "`Response`""></a></h4><p>The standard <code>Response</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/Response" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><p><strong>Streaming</strong>: You can pass a <a href="#readablestream"><code>ReadableStream</code></a> object as the <code>body</code> of a <code>Response</code> to stream the response as more data becomes available. Often, you won't need to implement the logic yourself as it is implemented by the frameworks and libraries you use.</p><h4 id="url" tabindex="-1"><code>URL</code> <a class="header-anchor" href="#url" aria-label="Permalink to "`URL`""></a></h4><p>The standard <code>URL</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>This URL implementation only supports URLs with a scheme.</p></div><h4 id="urlsearchparams" tabindex="-1"><code>URLSearchParams</code> <a class="header-anchor" href="#urlsearchparams" aria-label="Permalink to "`URLSearchParams`""></a></h4><p>The standard <code>URLSearchParams</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="file" tabindex="-1"><code>File</code> <a class="header-anchor" href="#file" aria-label="Permalink to "`File`""></a></h3><p>The standard <code>File</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/File" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="filereader" tabindex="-1"><code>FileReader</code> <a class="header-anchor" href="#filereader" aria-label="Permalink to "`FileReader`""></a></h3><p>The standard <code>FileReader</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="formdata" tabindex="-1"><code>FormData</code> <a class="header-anchor" href="#formdata" aria-label="Permalink to "`FormData`""></a></h3><p>The standard <code>FormData</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/FormData" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="navigator-useragent" tabindex="-1"><code>navigator.userAgent</code> <a class="header-anchor" href="#navigator-useragent" aria-label="Permalink to "`navigator.userAgent`""></a></h3><p><code>navigator.userAgent</code> is a fixed string that can be used to detect the current runtime. Its value is always <code>Lagoss/VERSION</code>, where <code>VERSION</code> is the current version of the Lagoss Runtime.</p><h3 id="process-env" tabindex="-1"><code>process.env</code> <a class="header-anchor" href="#process-env" aria-label="Permalink to "`process.env`""></a></h3><p>The only usage of <code>process</code> is to access environment variables. By default, it will only contain the <code>NODE_ENV</code> variable, which is set to <code>"production"</code> when deployed, and to <code>"development"</code> when using <a href="./cli.html#lagoss-dev"><code>lagoss dev</code></a>.</p><p><a href="./usage/environment-variables.html">Learn more about environment variables</a>.</p><h3 id="progressevent" tabindex="-1"><code>ProgressEvent</code> <a class="header-anchor" href="#progressevent" aria-label="Permalink to "`ProgressEvent`""></a></h3><p>The standard <code>ProgressEvent</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/ProgressEvent" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="stream-apis" tabindex="-1">Stream APIs <a class="header-anchor" href="#stream-apis" aria-label="Permalink to "Stream APIs""></a></h3><h4 id="readablestream" tabindex="-1"><code>ReadableStream</code> <a class="header-anchor" href="#readablestream" aria-label="Permalink to "`ReadableStream`""></a></h4><p>The standard <code>ReadableStream</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h4 id="readablestreamdefaultreader" tabindex="-1"><code>ReadableStreamDefaultReader</code> <a class="header-anchor" href="#readablestreamdefaultreader" aria-label="Permalink to "`ReadableStreamDefaultReader`""></a></h4><p>The standard <code>ReadableStreamDefaultReader</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h4 id="transformstream" tabindex="-1"><code>TransformStream</code> <a class="header-anchor" href="#transformstream" aria-label="Permalink to "`TransformStream`""></a></h4><p>The standard <code>TransformStream</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/TransformStream" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h4 id="writablestream" tabindex="-1"><code>WritableStream</code> <a class="header-anchor" href="#writablestream" aria-label="Permalink to "`WritableStream`""></a></h4><p>The standard <code>WritableStream</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/WritableStream" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h4 id="writablestreamdefaultwriter" tabindex="-1"><code>WritableStreamDefaultWriter</code> <a class="header-anchor" href="#writablestreamdefaultwriter" aria-label="Permalink to "`WritableStreamDefaultWriter`""></a></h4><p>The standard <code>WritableStreamDefaultWriter</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultWriter" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="textencoder" tabindex="-1"><code>TextEncoder</code> <a class="header-anchor" href="#textencoder" aria-label="Permalink to "`TextEncoder`""></a></h3><p>The standard <code>TextEncoder</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="textdecoder" tabindex="-1"><code>TextDecoder</code> <a class="header-anchor" href="#textdecoder" aria-label="Permalink to "`TextDecoder`""></a></h3><p>The standard <code>TextDecoder</code> object. <a href="https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h2 id="global-methods" tabindex="-1">Global methods <a class="header-anchor" href="#global-methods" aria-label="Permalink to "Global methods""></a></h2><h3 id="atob" tabindex="-1"><code>atob()</code> <a class="header-anchor" href="#atob" aria-label="Permalink to "`atob()`""></a></h3><p>The standard <code>atob</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/atob" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="btoa" tabindex="-1"><code>btoa()</code> <a class="header-anchor" href="#btoa" aria-label="Permalink to "`btoa()`""></a></h3><p>The standard <code>btoa</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/btoa" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="clearinterval" tabindex="-1"><code>clearInterval()</code> <a class="header-anchor" href="#clearinterval" aria-label="Permalink to "`clearInterval()`""></a></h3><p>The standard <code>clearInterval</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/clearInterval" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="cleartimeout" tabindex="-1"><code>clearTimeout()</code> <a class="header-anchor" href="#cleartimeout" aria-label="Permalink to "`clearTimeout()`""></a></h3><p>The standard <code>clearTimeout</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/clearTimeout" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="fetch" tabindex="-1"><code>fetch()</code> <a class="header-anchor" href="#fetch" aria-label="Permalink to "`fetch()`""></a></h3><p>The standard <code>fetch</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/fetch" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><div class="info custom-block"><p class="custom-block-title">INFO</p><p><code>fetch()</code> supports both HTTP/1.1 and HTTP/2. Additionally, there are <a href="./usage/limits.html#functions">some limits</a> in place to prevent abuses.</p></div><h3 id="queuemicrotask" tabindex="-1"><code>queueMicrotask()</code> <a class="header-anchor" href="#queuemicrotask" aria-label="Permalink to "`queueMicrotask()`""></a></h3><p>The standard <code>queueMicrotask</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="setinterval" tabindex="-1"><code>setInterval()</code> <a class="header-anchor" href="#setinterval" aria-label="Permalink to "`setInterval()`""></a></h3><p>The standard <code>setInterval</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/setInterval" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p><h3 id="settimeout" tabindex="-1"><code>setTimeout()</code> <a class="header-anchor" href="#settimeout" aria-label="Permalink to "`setTimeout()`""></a></h3><p>The standard <code>setTimeout</code> method. <a href="https://developer.mozilla.org/en-US/docs/Web/API/setTimeout" target="_blank" rel="noreferrer">See the documentation on MDN</a>.</p></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-09de1c0f><!--[--><!--]--><!----><nav class="prev-next" data-v-09de1c0f><div class="pager" data-v-09de1c0f><a class="VPLink link pager-link prev" href="/getting-started.html" data-v-09de1c0f><!--[--><span class="desc" data-v-09de1c0f>Previous page</span><span class="title" data-v-09de1c0f>Getting Started</span><!--]--></a></div><div class="pager" data-v-09de1c0f><a class="VPLink link pager-link next" href="/cli.html" data-v-09de1c0f><!--[--><span class="desc" data-v-09de1c0f>Next page</span><span class="title" data-v-09de1c0f>CLI</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
<script>window.__VP_HASH_MAP__=JSON.parse("{\"usage_account.md\":\"C9_xtxIe\",\"usage_logs.md\":\"CYi1T4oK\",\"self-hosting_installation.md\":\"DbP0ZG9Q\",\"usage_regions.md\":\"-dhRGrOk\",\"usage_assets.md\":\"C6GaJV4X\",\"usage_cron.md\":\"B3vI2t5q\",\"usage_deployments.md\":\"DrmzjEhc\",\"index.md\":\"BcD_NlRD\",\"usage_security.md\":\"li7Tnvjy\",\"usage_domains.md\":\"Dd091cC_\",\"contributing.md\":\"yZsRwz4D\",\"self-hosting_configuration.md\":\"C3WX_j5_\",\"usage_limits.md\":\"C0jqZFQy\",\"usage_pricing.md\":\"lJNWBUap\",\"runtime-apis.md\":\"jbG-txpu\",\"cli.md\":\"DQYfCWmm\",\"getting-started.md\":\"DgBv55-U\",\"usage_environment-variables.md\":\"DU_oi06y\",\"examples.md\":\"7Ptb0G4R\",\"introduction.md\":\"Ce0dD3Ro\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"Lagoss\",\"description\":\"An open-source runtime and platform that allows developers to run TypeScript and JavaScript Serverless Functions.\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"logo\":\"/icon-white.png\",\"nav\":[{\"text\":\"Home\",\"link\":\"/\"},{\"text\":\"Docs\",\"link\":\"/introduction\"}],\"sidebar\":[{\"text\":\"Introduction\",\"link\":\"/introduction\"},{\"text\":\"Getting Started\",\"link\":\"/getting-started\"},{\"text\":\"Runtime APIs\",\"link\":\"/runtime-apis\"},{\"text\":\"CLI\",\"link\":\"/cli\"},{\"text\":\"Examples\",\"link\":\"/examples\"},{\"text\":\"Usage\",\"collapsed\":false,\"items\":[{\"text\":\"Deployments\",\"link\":\"/usage/deployments\"},{\"text\":\"Assets\",\"link\":\"/usage/assets\"},{\"text\":\"Environment variables\",\"link\":\"/usage/environment-variables\"},{\"text\":\"Domains\",\"link\":\"/usage/domains\"},{\"text\":\"Logs\",\"link\":\"/usage/logs\"},{\"text\":\"Cron\",\"link\":\"/usage/cron\"},{\"text\":\"Limits\",\"link\":\"/usage/limits\"},{\"text\":\"Security\",\"link\":\"/usage/security\"}]},{\"text\":\"Self hosting\",\"collapsed\":true,\"items\":[{\"text\":\"Installation\",\"link\":\"/self-hosting/installation\"},{\"text\":\"Configuration\",\"link\":\"/self-hosting/configuration\"}]}],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/lagossapp/lagoss\"}]},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false}");</script>
</body>
</html>