quirrel-dev / quirrel

The Task Queueing Solution for Serverless.
https://quirrel.dev
MIT License
885 stars 67 forks source link

Bring Native support for Next.js App Directory #1138

Closed Skn0tt closed 1 year ago

Skn0tt commented 1 year ago

In https://github.com/quirrel-dev/quirrel/discussions/1136, users asked for how they can use the Next.js App Directory with Quirrel. We should build a ready-made integration.

KevinEdry commented 1 year ago

Waiting for this to happen, I cannot integrate Quirrel to my nextjs 13 codebase. would also love to see a workaround until this will be resolved.

gyto23 commented 1 year ago

@Skn0tt @KevinEdry

I dont think the queue is even working. I have already tried to run the new next-app. the cron jobs are invoking and they can return some console logs on server, however queue doesnt, nor setting queue for 3 seconds to invoke or manual invoke

image
export const docQueue = Queue(
  "/api/queue/doc",
  async (content_id: string) => {
    console.log("payload", content_id);
    const document = await getDocument(content_id);
    const modifiedAt = await getModifiedTime(content_id);

    const article = await prisma.article.update({
      data: {
        content: document,
        content_at: modifiedAt,
      },
      where: {
        content_id,
      }
    });

    revalidatePath(`/article/${article.id}`);
  }
)
export const POST = docQueue;

and I called it with (obvious)

 await docQueue.enqueue(
    id,
    {
      // runAt: today.add(3, "second").toDate(),
      runAt: today.add(10 + index, "minute").toDate(),
      id,
    },
gyto23 commented 1 year ago

@Skn0tt @KevinEdry

I dont think the queue is even working. I have already tried to run the new next-app. the cron jobs are invoking and they can return some console logs on server, however queue doesnt, nor setting queue for 3 seconds to invoke or manual invoke

image
export const docQueue = Queue(
  "/api/queue/doc",
  async (content_id: string) => {
    console.log("payload", content_id);
    const document = await getDocument(content_id);
    const modifiedAt = await getModifiedTime(content_id);

    const article = await prisma.article.update({
      data: {
        content: document,
        content_at: modifiedAt,
      },
      where: {
        content_id,
      }
    });

    revalidatePath(`/article/${article.id}`);
  }
)
export const POST = docQueue;

and I called it with (obvious)

 await docQueue.enqueue(
    id,
    {
      // runAt: today.add(3, "second").toDate(),
      runAt: today.add(10 + index, "minute").toDate(),
      id,
    },

My mistake, Incorrect Base url in env was setup