Next.js Discord

Discord Forum

Trying to build a queue for Next js 13 with custom api ( bull, next.js, redis)

Unanswered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
Hi developers i am trying to work on queue in next.js 13 with a custom api.

This is how far I got... the api is working the connection to redis is working but the middle is not working im trying to build the queue to learn and to grow for my personal project.

I'm stuck for 3 days now I did 1 script 2 script and a 3 script use that I just cut it in pieces, still no luck so I try my luck here.

im getting the following error:

Error: No .lua files found!
at loadScripts (webpack-internal:///(rsc)/./node_modules/bull/lib/commands/index.js:29:15)
at async eval (webpack-internal:///(rsc)/./node_modules/bull/lib/commands/index.js:18:19)
✅ Redis Connected Successfully
api/temp/route.js

import { NextResponse } from "next/server";
const Queue = require('bull');
import { connectToRedis } from "@/lib/redis";

export async function createQueue() {
const redis = await connectToRedis();
const queue = new Queue('my-queue', { redis: { client: redis, }, });
return queue;
}

export async function addJob(queue, job) {
await queue.add(job);
}

export async function POST(request) {
try {
const queue = await createQueue();
await addJob(queue, { name: "John", age: 30 });
return NextResponse.json({ message: "Hello, redis, bull API" }, { status: 200 });
} catch (error) {
console.log(error);
return NextResponse.json({ message: "An error occured by creating a que."}, { status: 500 });
}
}

https://stackoverflow.com/questions/77188549/trying-to-build-a-queue-for-next-js-13-with-custom-api-bull-next-js-redis

0 Replies