# @lagon/runtime

> JavaScript Serverless Runtime for Lagon

Latest version **0.0.6** (published 2022-08-22) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @lagon/runtime
pnpm add @lagon/runtime
yarn add @lagon/runtime
bun add @lagon/runtime
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2022-08-22 |
| First published | 2022-07-01 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 51.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | quiibz |

## Links

- npm: https://www.npmjs.com/package/@lagon/runtime
- npm.io page: https://npm.io/package/@lagon/runtime

## Dependencies (2)

- [isolated-vm](https://npm.io/package/isolated-vm.md) ^4.4.1
- [web-streams-polyfill](https://npm.io/package/web-streams-polyfill.md) ^3.2.1

## Recent versions

- 0.0.6 (latest) — 2022-08-22
- 0.0.5 — 2022-08-12
- 0.0.4 — 2022-08-07
- 0.0.3 — 2022-07-09
- 0.0.2 — 2022-07-02
- 0.0.1 — 2022-07-01

## README

# Lagon
JavaScript Serverless Runtime

## API
```ts
const deployment: Deployment = {
  functionId: 'custom-id',
  deploymentId: 'custom-id',
  domains: ['localhost:3000'],
  memory: 128,
  timeout: 50,
  env: {
    hello: 'world',
  },
  isCurrent: true,
}

function getDeploymentCode(deployment) {
  return `export async function handler(request) {
    return new Response("Hello world!")
  }`
}

const runIsolate = await getIsolate({
  deployment,
  getDeploymentCode,
})

const request: HandlerRequest  = {
  input: '/test',
  options: {
    method: 'GET',
    headers: {},
    body: 'request body',
  },
}

const { response } = await runIsolate(request)
```

## Runtime

### Request
```ts
new Request(input [, options])
```

#### Constructor
- `input: string`
- `options?: RequestInit`

##### RequestInit
- `method?: string`
- `headers?: Record<string, string | string[] | undefined>`
- `body?: string`

#### Properties
- `method: string`
- `headers: Record<string, string | string[] | undefined>`
- `body: string`
- `url: string`

#### Methods
- `text(): Promise<string>`
- `json<T>(): Promise<T>`
- `formData(): Promise<Record<string, string>>`

### Response
```ts
new Response(body [, options])
```

#### Constructor
- `body: string`
- `options?: ResponseInit`

##### ResponseInit
- `status?: string`
- `statusText?: string`
- `headers?: Record<string, string | string[] | undefined>`
- `url?: string`

#### Properties
- `body: string`
- `headers: Record<string, string | string[] | undefined>`
- `ok: boolean`
- `status: number`
- `statusText: string`
- `url: string`

#### Methods
- `text(): Promise<string>`
- `json<T>(): Promise<T>`
- `formData(): Promise<Record<string, string>>`

## Fetch
```ts
fetch(resource [, init]): Promise<Response>
```

### Parameters
- `resource: string`
- `init?: RequestInit`

### Environment variables
```ts
MY_VARIABLE
```

### Console
```ts
console.log(...args: any[])
console.error(...args: any[])
console.info(...args: any[])
console.warn(...args: any[])
console.debug(...args: any[])
```

---
_Source: https://npm.io/package/@lagon/runtime · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
