27 lines
808 B
TypeScript
27 lines
808 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import checkHealth from '../../../worker/health';
|
|
import Redis from 'ioredis';
|
|
import { Queue } from 'bullmq';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const health = checkHealth();
|
|
|
|
const redisUrl = process.env.REDIS_URL;
|
|
let queueInfo = null;
|
|
|
|
if (redisUrl) {
|
|
const connection = new Redis(redisUrl);
|
|
const queue = new Queue('intune-sync-queue', { connection });
|
|
const counts = await queue.getJobCounts();
|
|
queueInfo = counts;
|
|
await queue.close();
|
|
await connection.quit();
|
|
}
|
|
|
|
return NextResponse.json({ ok: true, health, queue: queueInfo, timestamp: new Date().toISOString() });
|
|
} catch (err: any) {
|
|
return NextResponse.json({ ok: false, error: err?.message || String(err) }, { status: 500 });
|
|
}
|
|
}
|