0.0.6 • Published 3 years ago
@lagon/runtime v0.0.6
Lagon
JavaScript Serverless Runtime
API
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
new Request(input [, options])Constructor
input: stringoptions?: RequestInit
RequestInit
method?: stringheaders?: Record<string, string | string[] | undefined>body?: string
Properties
method: stringheaders: Record<string, string | string[] | undefined>body: stringurl: string
Methods
text(): Promise<string>json<T>(): Promise<T>formData(): Promise<Record<string, string>>
Response
new Response(body [, options])Constructor
body: stringoptions?: ResponseInit
ResponseInit
status?: stringstatusText?: stringheaders?: Record<string, string | string[] | undefined>url?: string
Properties
body: stringheaders: Record<string, string | string[] | undefined>ok: booleanstatus: numberstatusText: stringurl: string
Methods
text(): Promise<string>json<T>(): Promise<T>formData(): Promise<Record<string, string>>
Fetch
fetch(resource [, init]): Promise<Response>Parameters
resource: stringinit?: RequestInit
Environment variables
MY_VARIABLEConsole
console.log(...args: any[])
console.error(...args: any[])
console.info(...args: any[])
console.warn(...args: any[])
console.debug(...args: any[])