Expired sign-in, save-progress, email-change, and invitation tokens (and any draft they carry) are cleared by a Cloudron scheduler task. Page timing logs record the path without the query string, and mail failures log a request id instead of an address.
22 lines
1016 B
TypeScript
22 lines
1016 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { apiRoute } from "../../../../lib/server/apiRoute";
|
|
import { prisma } from "../../../../lib/server/db";
|
|
import { getOpsPruneToken, isDatabaseConfigured } from "../../../../lib/server/env";
|
|
import { pruneExpiredRecords } from "../../../../lib/server/pruneExpiredRecords";
|
|
import { dbUnavailable, notFound, unauthorized } from "../../../../lib/server/responses";
|
|
import { retryPendingWorkshopInquiryMail } from "../../../../lib/server/workshopSignup";
|
|
|
|
export const POST = apiRoute("ops.prune", async (request: NextRequest) => {
|
|
const token = getOpsPruneToken();
|
|
if (!token) return notFound();
|
|
|
|
const header = request.headers.get("authorization") ?? "";
|
|
if (header !== `Bearer ${token}`) return unauthorized();
|
|
if (!isDatabaseConfigured()) return dbUnavailable();
|
|
|
|
const retried = await retryPendingWorkshopInquiryMail();
|
|
const pruned = await pruneExpiredRecords(prisma);
|
|
|
|
return NextResponse.json({ ok: true, retried, ...pruned });
|
|
});
|