Closed
Description
Overview:
While we build our official integrations, we want to create examples of how to create jobs which use other APIs with Trigger.dev. This reference will be used in the app on any service we don’t have an integration for yet.
Details:
In this example, you will build a simple job which uses the AWS API. This will replace the GitHub example we currently have in the app:
Requirements:
- Use the structure of our GitHub API reference file.
- The job must connect to the AWS API, using their official SDK
- The job must query a DynamoDB table and return a payload or invoke a lambda function
Guidelines:
- The job should use an
eventTrigger
. - The job should use
zod
to define the payloads. - Use native fetch where no official SDK or incompatible auth
- Only use
io.backgroundFetch()
where absolutely necessary - Avoid external packages apart from official SDKs
- Prefer REST over GraphQL - avoid raw queries
- Use a minimal
io.runTask()
callback - initialise clients and auth in global scope if possible - Leave clear comments with links to relevant developer docs, API key pages etc. The Discord example is the level of commenting we are looking for.
Required Structure:
- Follow this guide to get the project setup.
- Create a new file in the src folder, named to match the API (e.g. GitHub would be called github.ts).
- The Trigger.dev client must be defined at the top of the job, with the 'api-reference' id:
const client = new TriggerClient({ id: "api-reference" });
4. You must add the Express specific lines to the bottom of the Job file:
// These lines can be removed if you don't want to use express
import { createExpressServer } from "@trigger.dev/express";
createExpressServer(client);
5. You must add the new script to the package.json file, in this format:
"scripts": {
//..other scripts
"<api-name>": "nodemon --watch src/<api name>.ts -r tsconfig-paths/register -r dotenv/config src/<api name>.ts"
}
Important
You must test this Job works before submitting your PR, including a screenshot of a successful run. This may involve you having to setup accounts with services.