This is an example function for Airsequel Functions written in PureScript.
- Install all dependencies:
npm install
- Write your code in
src/Main.purs
- Create the JavaScript bundle:
make bundle
- Copy and paste the content of
index.js
to your Airsequel function![NOTE] We'll add a script to upload the function directly to Airsequel in the future
Since the bundle generated by Spago (PureScript's package manager)
is not fully compatible with Airsequel Functions,
following additional steps are executed by make bundle
:
-
npx spago bundle \ --platform node \ --bundle-type module \ --minify
- Prefix imports with
node:
:- import __module from 'module'; - import __path from 'path'; - import __url from 'url'; + import __module from 'node:module' + import __path from 'node:path' + import __url from 'node:url'
- Remove useless
const …
at the beginning:- const require = … - const __dirname = … - const __filename = …
- Export a default wrapper function:
- export { x as main }; + export default async function main(context) { + return x(context)() + }