cba5d9c3ac
Sticky sidebar with back-to-app link. Overview: user counts, recipe photos, AI calls/month. User management with role/tier editing. Audit log (all admin actions). Storage page with photo breakdown by tier. AI config showing DB vs .env key source. Site settings page to override .env values at runtime (encrypted in DB).
27 lines
882 B
TypeScript
27 lines
882 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { requireAdmin } from "@/lib/api-auth";
|
|
import { sendEmail, verifyEmailHtml } from "@/lib/email";
|
|
|
|
export async function POST(req: NextRequest) {
|
|
const { response } = await requireAdmin();
|
|
if (response) return response;
|
|
|
|
const { to } = await req.json() as { to: string };
|
|
if (!to) return NextResponse.json({ error: "Missing 'to'" }, { status: 400 });
|
|
|
|
try {
|
|
await sendEmail({
|
|
to,
|
|
subject: "Epicure — test email",
|
|
html: verifyEmailHtml(`${process.env["BETTER_AUTH_URL"] ?? "http://localhost:3001"}/verify-email?token=test`),
|
|
});
|
|
return NextResponse.json({
|
|
ok: true,
|
|
smtp_host: process.env["SMTP_HOST"] ?? null,
|
|
smtp_user: process.env["SMTP_USER"] ?? null,
|
|
});
|
|
} catch (err) {
|
|
return NextResponse.json({ error: String(err) }, { status: 500 });
|
|
}
|
|
}
|