Suborbital
Search…
Create a custom library
To continue to tailor your users' experience to your product, you can create a custom library with functions and utilities designed specifically for your product. For example, your users will import library functions from @acmeco/acmeco instead of @suborbital/suborbital, and you'll be able to export library functions such as acmeco.getUsers versus the plain suborbital.httpGet.
We want to help! Creating custom templates and libraries are an important aspect of Compute, so send us an email and we'll help you make the most out of these abilities.

Setup

We provide a base library for you to modify and publish to the language-specific package manager, which can then be included as a project dependency in a custom function template.
Custom libraries are currently only officially supported for AssemblyScript, with more coming soon.
If you haven't already, create a fork of the runnable-templates git repository:
Once the repo has been forked into your company or personal account, you can begin editing the libraries in the library directory.

AssemblyScript

The AssemblyScript library is located in library/assemblyscript. As your custom library will need to be published, you will need to give it a custom name. In library/assemblyscript/package.json, replace all instances of acmeco with your desired name. Add your custom library as a dependency in templates/assemblyscript/package.json.tmpl so your users' functions can use it:
1
"dependencies": {
2
"@assemblyscript/loader": "^0.19",
3
"@acmeco/acmeco": "^0.1.0" // your library here
4
}
Copied!
You can modify library/assemblyscript/assembly/index.ts to expose new utility functions and/or remove existing ones. To learn more about the available APIs, check out Atmo's Runnable API docs.
Once this is done, publish your library to npm:
1
cd library/assemblyscript
2
npm publish --access public
Copied!

Configuring Compute

Since your custom library is listed as a dependency of the template project, it will be installed when your users' functions are built for the first time.
In your Compute installation, you will need to configure the SCC_TEMPLATES_REPO environment variable.
  • For a local deployment, edit docker-compose.yml to add SCC_TEMPLATES_REPO: to the builder with the value set to your fork (e.g. acmeco/runnable-templates)
  • For a cloud deployment, edit suborbital/scc-controlplane.yaml, and add the following to the builder container's environment:
1
- name: SCC_TEMPLATES_REPO
2
value: "{your fork}"
Copied!
Then run kubectl apply -f .suborbital/ to apply the change.
Last modified 2mo ago
Export as PDF
Copy link