I want to create jobs/workers for functions that use external APIs such as OpenAI so they're also processed if the user closes/refrehes the page.
Example: For an outline creation function I have created: 1) a job definition in the main.wasp: job createOutlineJob { executor: PgBoss, perform: { fn: import { createOutlineWorker } from "@src/server/workers/outlineWorker" }, entities: [User, Keyword, Headline, Websites] } 2) an OutlineWorker,ts file in ..\app\src\server\workers that contains all helper functions for the main createOutlineWorker function and of course the createOutlineWorker function itself: export const createOutlineWorker: CreateOutlineJob<Input, Output> = async ({ keywordId }, context) => { 3) reference on an app page: import { createOutlineJob } from 'wasp/server/jobs'; ... const handleCreateOutline = async (keywordId) => { try { await createOutlineJob.submit({ keywordId: keywordId }); } catch (error) { console.error('Failed to enqueue createOutlineJob:', error); } };
Still, I get this error and a blank page when i try to build: ReferenceError: process is not defined at config.ts:41:20
I've already read that this seems to be server code that's loaded in the client but having a hard time to figure out what to do about it :/
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
W
Wasp
Rails-like framework for React, Node.js and Prisma. Build your app in a day and deploy it with a single CLI command.