Initial commit from Create Next App

This commit is contained in:
Atakan Doğan Özban
2026-07-12 15:40:35 +02:00
commit a0ca85a63d
52 changed files with 10164 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import { Redis } from "ioredis";
import { Queue } from "bullmq";
import { QUEUE_NAME } from "./constants";
import type { VideoJobData } from "./types";
let connection: Redis | null = null;
let queue: Queue<VideoJobData> | null = null;
export function getRedisConnection(): Redis {
if (!connection) {
connection = new Redis(process.env.REDIS_URL || "redis://localhost:6379", {
maxRetriesPerRequest: null,
});
}
return connection;
}
export function getVideoQueue(): Queue<VideoJobData> {
if (!queue) {
queue = new Queue<VideoJobData>(QUEUE_NAME, {
connection: getRedisConnection(),
});
}
return queue;
}
export async function enqueueVideoJob(data: VideoJobData) {
const q = getVideoQueue();
await q.add("process-video", data, {
attempts: 2,
backoff: { type: "exponential", delay: 5000 },
removeOnComplete: 100,
removeOnFail: 200,
});
}