File name
Commit message
Commit date
File name
Commit message
Commit date
09-16
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
import { getSessionAccessToken, verifySession } from '@/lib/auth/dal';
import { backendFetchStream } from '@/lib/http/backend-fetch';
const ADMIN_MEMBER_EXCEL_PATH = '/api/v1/mngr/admin/excel/download';
const EXCEL_ROW_LIMIT = 100_000;
const EXCEL_TIMEOUT_MS = 60_000;
const DOWNLOAD_FAILED_MESSAGE =
'엑셀 파일을 내려받지 못했습니다. 잠시 후 다시 시도해 주세요.';
const XLSX_CONTENT_TYPE =
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
export async function GET() {
await verifySession();
const accessToken = await getSessionAccessToken();
const result = await backendFetchStream(ADMIN_MEMBER_EXCEL_PATH, {
query: { pageIndex: 1, recordCountPerPage: EXCEL_ROW_LIMIT },
accessToken: accessToken ?? undefined,
timeoutMs: EXCEL_TIMEOUT_MS,
});
if (!result.ok) {
return new Response(DOWNLOAD_FAILED_MESSAGE, {
status: 502,
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
});
}
const upstream = result.data;
return new Response(upstream.body, {
status: 200,
headers: {
'Content-Type': upstream.headers.get('content-type') ?? XLSX_CONTENT_TYPE,
'Content-Disposition':
upstream.headers.get('content-disposition') ??
'attachment; filename="admins.xlsx"',
},
});
}