Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an example job using the Square API #41

Closed
D-K-P opened this issue Oct 26, 2023 · 0 comments · Fixed by #73
Closed

Create an example job using the Square API #41

D-K-P opened this issue Oct 26, 2023 · 0 comments · Fixed by #73

Comments

@D-K-P
Copy link
Member

D-K-P commented Oct 26, 2023

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 Square API. This will replace the GitHub example we currently have in the app:

2023-10-26 7

Requirements:

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:

  1. Follow this guide to get the project setup.​
  2. Create a new file in the src folder, named to match the API (e.g. GitHub would be called github.ts).​
  3. 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.

biplobsd added a commit to biplobsd/api-reference that referenced this issue Oct 28, 2023
@D-K-P D-K-P closed this as completed in #73 Oct 30, 2023
D-K-P pushed a commit that referenced this issue Oct 30, 2023
* Added square example (#41)

* Fixes spaces and reduce line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant