Updated the example job (#288)
* Changed the example job to include a delay * Improved the example job copy and added ‘in a separate terminal’ to 2. * Create kind-eggs-pump.md --------- Co-authored-by: Matt Aitken <matt@mattaitken.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@trigger.dev/cli": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Updated the example job
|
||||||
@@ -157,7 +157,7 @@ async function printNextSteps(options: ResolvedOptions, authorizedKey: WhoamiRes
|
|||||||
logger.info("Next steps:");
|
logger.info("Next steps:");
|
||||||
logger.info(` 1. Run your Next.js project locally with 'npm run dev'`);
|
logger.info(` 1. Run your Next.js project locally with 'npm run dev'`);
|
||||||
logger.info(
|
logger.info(
|
||||||
` 2. Run 'npx @trigger.dev/cli@latest dev' to watch for changes and automatically register Trigger.dev jobs`
|
` 2. In a separate terminal, run 'npx @trigger.dev/cli@latest dev' to watch for changes and automatically register Trigger.dev jobs`
|
||||||
);
|
);
|
||||||
logger.info(` 3. View your jobs at ${projectUrl}`);
|
logger.info(` 3. View your jobs at ${projectUrl}`);
|
||||||
|
|
||||||
@@ -481,22 +481,31 @@ export const client = new TriggerClient({
|
|||||||
import { eventTrigger } from "@trigger.dev/sdk";
|
import { eventTrigger } from "@trigger.dev/sdk";
|
||||||
import { client } from "${jobsPathPrefix}trigger";
|
import { client } from "${jobsPathPrefix}trigger";
|
||||||
|
|
||||||
// your first job
|
// Your first job
|
||||||
|
// This Job will be triggered by an event, log a joke to the console, and then wait 5 seconds before logging the punchline
|
||||||
client.defineJob({
|
client.defineJob({
|
||||||
|
// This is the unique identifier for your Job, it must be unique across all Jobs in your project
|
||||||
id: "example-job",
|
id: "example-job",
|
||||||
name: "Example Job",
|
name: "Example Job: a joke with a delay",
|
||||||
version: "0.0.1",
|
version: "0.0.1",
|
||||||
|
// This is triggered by an event using eventTrigger. You can also trigger Jobs with webhooks, on schedules, and more: https://trigger.dev/docs/documentation/concepts/triggers/introduction
|
||||||
trigger: eventTrigger({
|
trigger: eventTrigger({
|
||||||
name: "example.event",
|
name: "example.event",
|
||||||
}),
|
}),
|
||||||
run: async (payload, io, ctx) => {
|
run: async (payload, io, ctx) => {
|
||||||
await io.logger.info("Hello world!", { payload });
|
// This logs a message to the console
|
||||||
|
await io.logger.info("🧪 Example Job: a joke with a delay");
|
||||||
return {
|
await io.logger.info("How do you comfort a JavaScript bug?");
|
||||||
message: "Hello world!",
|
// This waits for 5 seconds, the second parameter is the number of seconds to wait, you can add delays of up to a year
|
||||||
};
|
await io.wait("Wait 5 seconds for the punchline...", 5);
|
||||||
|
await io.logger.info("You console it! 🤦");
|
||||||
|
await io.logger.info(
|
||||||
|
"✨ Congratulations, You just ran your first successful Trigger.dev Job! ✨"
|
||||||
|
);
|
||||||
|
// To learn how to write much more complex (and probably funnier) Jobs, check out our docs: https://trigger.dev/docs/documentation/guides/create-a-job
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const examplesIndexContent = `
|
const examplesIndexContent = `
|
||||||
|
|||||||
Reference in New Issue
Block a user