templates2.Admin.Next/app/api/admin/export/customers/route.ts
w4c-templates c64f7ffa9e
Some checks failed
CI / quality (push) Has been cancelled
chore(template): publish Admin.Next
2026-10-11 23:25:34 +03:00

19 lines
507 B
TypeScript

import { apiStaff } from '@/lib/server/guard';
import { exportCustomersCsv } from '@/lib/server/crm';
export const dynamic = 'force-dynamic';
/** Download every customer as a CSV attachment. */
export async function GET() {
const g = await apiStaff();
if (g.error) return g.error;
const csv = await exportCustomersCsv();
return new Response(csv, {
headers: {
'Content-Type': 'text/csv; charset=utf-8',
'Content-Disposition': 'attachment; filename="customers.csv"',
},
});
}