19 lines
507 B
TypeScript
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"',
|
|
},
|
|
});
|
|
}
|