echos-ocr/src/app/api/email-watch/poll/route.ts

13 lines
429 B
TypeScript
Raw Normal View History

import { NextRequest, NextResponse } from "next/server";
import { scanInbox } from "@/lib/email-watcher";
export async function GET(request: NextRequest) {
const authHeader = request.headers.get("authorization");
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const result = await scanInbox();
return NextResponse.json(result);
}