The OpenFaas template with Node 16 and TypeScript support and handler function types.
In order to run this template you need to install openfaas and faas-cli. Instructions here: https://docs.openfaas.com/cli/install/
- Run
faas-cli template pull https://github.com/pawelotto/openfaas-node16-typescript - Run
faas-cli new --listto verify the template has been added asnode16-typescriptlanguage - Run
faas-cli new <your_function_name> --lang node16-typescriptto scaffold the function directory and files - Edit the
<your_function_name>.ymlfile:
- add
/distat the end of the handler entry because that's where your output handler.js file will be built to - specify your Docker repo in the
imageyaml entry. If you're using a private Docker repo make sure to add your secret to the openfaas cluster: (https://docs.openfaas.com/reference/private-registries/)
- Chdir to
<your_function_name>and runyarnto install dependencies - Edit
<your_function_name>/src/handler.tsto match your needs - Run
yarn faas:buildto compile ts sources and copy package.json file - Run
faas-cli login -g <your_faas_gateway_address> --password <password> - Chdir up to main dir and run
faas-cli up -f <your_function_name>.ymlto build, push and deploy your function