Skip to content

Conversation

@H4ad
Copy link
Contributor

@H4ad H4ad commented Sep 9, 2023

/claim #449

This PR adds a basic integration with NestJS by exporting TriggerClient through @InjectTriggerDevClient() decorator.

Images

image

image

image

image

Suggestions for the next iterations

For now, I focus only on adding the initial structure and documentation for this integration.

NestJS can be very extensive, and one of the APIs we can add to integrate Trigger.dev can be something like this:

export interface TriggerDevJobConsumer<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> {
  getTrigger(): TTrigger;
  run: (payload: TriggerEventType<TTrigger>, io: IOWithIntegrations<TIntegrations>, context: TriggerContext) => Promise<any>;
}

@Job({
  id: "test-job",
  name: "Test Job One",
  version: "0.0.1",
})
export class MyCustomJobConsumer {
  public getTrigger() {
    return eventTrigger({
      name: "test.event",
    });
  }

  public async run(payload, io, ctx) {
    await io.logger.info("Hello world!", { payload });

    return {
      message: "Hello world!",
    };
  }
}

Then, you just need to import MyCustomJobConsumer in any module and it will automatically register the Job.

But I suggest first creating an issue describing an Interface for this consumer and then trying to create this feature.

@changeset-bot
Copy link

changeset-bot bot commented Sep 9, 2023

⚠️ No Changeset found

Latest commit: 65908c6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@matt-aitken
Copy link
Member

This is a great PR.

We made some major changes on the platform side, so I had to modify your branch a bit to get it merged. But that's now done and merged: #574. I'll tip you using Algora now on the issue.

Sorry it took so long, the platform changes made all of the framework PRs a nightmare… 🤦

Thanks a lot 🙏

@matt-aitken matt-aitken closed this Oct 6, 2023
@H4ad H4ad deleted the feat/nestjs branch October 6, 2023 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants