chore: add hello world task

This commit is contained in:
javayhu 2025-06-23 01:03:11 +08:00
parent 57fa9a0136
commit 13bada6a64
2 changed files with 34 additions and 0 deletions

View 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',
};
}
}

View 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!',
};
},
});