File size: 1,135 Bytes
7895d85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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