how to2 min readv1
Add a Function, Service or Job
A Slice’s web app and handlers cover most products. When a feature needs a different way of running, add a workload inside the same Slice.
Choose the kind
| Kind | Runs as | Use it for |
|---|---|---|
| Function | One Lambda function behind a named route | A single operation, such as a form submission or a webhook. |
| Service | A continuous process | Work that must stay running. |
| Job | A process that starts, finishes and exits | Batch work and one-off tasks. |
Generate it
bash
pnpm nx g @empire-builder-kit/nx:function invoice --slice=billing --feature=operations
pnpm nx g @empire-builder-kit/nx:service worker --slice=billing --feature=operations
pnpm nx g @empire-builder-kit/nx:job reconcile --slice=billing --feature=eventsEach generator takes the workload’s name, the Slice that owns it and a feature name used in its logs.
Who may call a Function
A Function is either signed-in, which requires a Cognito access token, or anonymous. Change the setting with the function-access generator; it takes effect on the next deploy.
bash
pnpm nx g @empire-builder-kit/nx:function-access invoice --slice=billing --authentication=anonymousContinue building