in src/app/api/mock/resetTestData/route.ts [23:52]
export async function GET(req: NextRequest) {
const prodError = errorIfProduction();
if (prodError) return prodError;
const session = await getServerSession();
const email = session?.user.email;
const subscriberId = session?.user.subscriber?.id;
if (!session || !email || !isTestEmail(email) || !subscriberId)
return unauthError();
const hibp = req.nextUrl.searchParams.get("hibp") === "true";
const onerep = req.nextUrl.searchParams.get("onerep") === "true";
const onerepProfileId = await getOnerepProfileId(subscriberId);
if (!onerepProfileId)
return internalServerError("Unable to fetch OneRep profile ID");
if (onerep) {
await deleteScanResultsForProfile(onerepProfileId);
await deleteSomeScansForProfile(onerepProfileId, 1);
}
if (hibp) await unresolveAllBreaches(onerepProfileId);
logger.info(
"Mock OneRep endpoint: attempted to delete all but 1 scans, attempted to unresolve all breaches",
);
return NextResponse.json(
{ message: "Requested reached successfully" },
{ status: 200 },
);
}