Co-authored-by: Carina Wollendorfer <[email protected]> Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: zomars <[email protected]>
22 lines
600 B
TypeScript
22 lines
600 B
TypeScript
import type { NextRequest } from "next/server";
|
|
import { NextResponse } from "next/server";
|
|
|
|
import tasker from "..";
|
|
|
|
async function handler(request: NextRequest) {
|
|
const authHeader = request.headers.get("authorization");
|
|
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
|
|
return new Response("Unauthorized", { status: 401 });
|
|
}
|
|
await tasker.processQueue();
|
|
return NextResponse.json({ success: true });
|
|
}
|
|
|
|
export async function GET(request: NextRequest) {
|
|
return await handler(request);
|
|
}
|
|
|
|
export async function POST(request: NextRequest) {
|
|
return await handler(request);
|
|
}
|