Spaces:
Sleeping
Sleeping
import { L as LogService } from './LogService-P6XVmjfT.js'; | |
import 'fs'; | |
import 'path'; | |
import 'util'; | |
import 'date-fns'; | |
import 'mongoose'; | |
import 'exceljs'; | |
import './shared-server-49TKSBDM.js'; | |
const logService = new LogService(); | |
const GET = async ({ url }) => { | |
try { | |
const dateFrom = url.searchParams.get("dateFrom"); | |
const dateTo = url.searchParams.get("dateTo"); | |
const dateFromObj = dateFrom ? new Date(dateFrom) : void 0; | |
const dateToObj = dateTo ? new Date(dateTo) : void 0; | |
const buffer = await logService.export("excel", dateFromObj, dateToObj); | |
return new Response(buffer, { | |
headers: { | |
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | |
"Content-Disposition": 'attachment; filename="logs.xlsx"' | |
} | |
}); | |
} catch (error) { | |
console.error("Error while exporting logs to Excel:", error); | |
return new Response(JSON.stringify({ message: "Failed to export logs to Excel" }), { | |
status: 500, | |
headers: { "Content-Type": "application/json" } | |
}); | |
} | |
}; | |
export { GET }; | |
//# sourceMappingURL=_server.ts-F5NjTnvI.js.map | |