import { HyrexRegistry } from '@hyrex/hyrex';import { getHyrexContext } from '@hyrex/hyrex';export const hy = new HyrexRegistry();// Define a simple hello world taskconst helloWorldTask = hy.task({ name: 'helloWorld', config: { queue: 'default', timeoutSeconds: 30, }, func: async (input: { name?: string }) => { const ctx = getHyrexContext(); const name = input.name || 'World'; console.log(`Task ID: ${ctx.taskId}`); console.log(`Hello, ${name}! Welcome to Hyrex!`); // Simulate some work await new Promise(resolve => setTimeout(resolve, 2000)); return { message: `Successfully greeted ${name}`, timestamp: new Date().toISOString(), taskId: ctx.taskId }; }});
Example hyrex-app.ts:
Copy
Ask AI
import { HyrexApp } from '@hyrex/hyrex';import { hy as appRegistry } from './app';const hyrexApp = new HyrexApp({ name: "My Cool App"});hyrexApp.addRegistry(appRegistry);hyrexApp.init();