Service: Birme Lambda - EyevinnOSC/community GitHub Wiki
Birme Lambda (serviceId birme-lambda) runs JavaScript or TypeScript code as an HTTP-based lambda function. You upload a zip file with your code and the instance executes it on each HTTP request. It is a long-running service instance with up to 1 GiB of storage per instance. License: MIT.
- Run a
handlerfunction from uploaded JavaScript/TypeScript code when an HTTP request arrives. - Accept new code at any time by uploading a zip file to the instance.
- Serve as a lightweight HTTP-triggered function endpoint without building a container image.
Create the instance with create-service-instance using serviceId: "birme-lambda" and a config object. The instance name must be alphanumeric and at most 20 characters. Birme Lambda has no dependencies on other OSC services.
{ "name": "guide" }Wait for the instance to become ready with wait-for-service-ready, then use describe-service-instance to get its URL. The instance is served at https://<tenant>-<name>.birme-lambda.auto.prod-se.osaas.io, where <tenant> is the id of your tenant.
| Option | Required | Type | Meaning |
|---|---|---|---|
| name | Yes | string | Name of the instance. Alphanumeric, at most 20 characters. It becomes part of the instance URL. |
The service has no other options.
Create a file index.js that exports a handler function:
exports.handler = async (event) => {
console.log(event);
const res = {
body: {
message: 'hello world'
}
};
return res;
}Package it and upload it to the /upload endpoint. The upload requires a service access token (SAT) as a bearer token. See Service Access Tokens for how to acquire one.
% zip example.zip index.js
% curl -v -F [email protected] -H 'Authorization: Bearer <SAT>' https://<tenant>-<name>.birme-lambda.auto.prod-se.osaas.io/upload
Run the code by sending an HTTP request with a JSON body to the /event endpoint. The body returned by the handler is the response:
% curl -v -X POST -H 'Content-Type: application/json' -d '{ "hej": "hopp" }' https://<tenant>-<name>.birme-lambda.auto.prod-se.osaas.io/event
{"message":"hello world"}
- Storage is limited to 1 GiB per instance.