Files
expense-control/api/src/utils/http.ts
Mateusz Gruszczyński ca9c78d88d changes
2026-04-07 10:06:48 +02:00

15 lines
523 B
TypeScript

import type { Proof } from '../entities/Proof.js';
export const buildProofUrl = (storedName: string | null) => storedName ? `/uploads/${storedName}` : null;
export const serializeProof = (proof: Proof, _expenseId?: string) => ({
id: proof.id,
type: proof.type,
label: proof.label,
note: proof.note,
originalName: proof.originalName,
mimeType: proof.mimeType,
fileSize: proof.fileSize,
fileUrl: buildProofUrl(proof.storedName),
previewUrl: buildProofUrl(proof.storedName),
createdAt: proof.createdAt
});