chore: add hello world task
This commit is contained in:
parent
57fa9a0136
commit
13bada6a64
20
src/actions/hello-world-task.ts
Normal file
20
src/actions/hello-world-task.ts
Normal file
@ -0,0 +1,20 @@
|
||||
'use server';
|
||||
|
||||
import type { helloWorldTask } from '@/trigger/hello-world';
|
||||
import { tasks } from '@trigger.dev/sdk/v3';
|
||||
|
||||
export async function myTask() {
|
||||
try {
|
||||
const handle = await tasks.trigger<typeof helloWorldTask>(
|
||||
'hello-world',
|
||||
'James'
|
||||
);
|
||||
|
||||
return { handle };
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return {
|
||||
error: 'something went wrong',
|
||||
};
|
||||
}
|
||||
}
|
14
src/trigger/hello-world.ts
Normal file
14
src/trigger/hello-world.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { logger, task, wait } from '@trigger.dev/sdk/v3';
|
||||
|
||||
export const helloWorldTask = task({
|
||||
id: 'hello-world',
|
||||
run: async (payload: any, { ctx }) => {
|
||||
logger.log('Hello, world!', { payload, ctx });
|
||||
|
||||
await wait.for({ seconds: 5 });
|
||||
|
||||
return {
|
||||
message: 'Hello, world!',
|
||||
};
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue
Block a user