Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: zomars <zomars@me.com>
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);
|
|
}
|