feat: contain DTO mapping at the HTTP boundary

This commit is contained in:
donghyeon-ka
2026-07-25 21:02:06 +09:00
parent 3e126c0ddd
commit a9a7db0231
6 changed files with 178 additions and 8 deletions
@@ -0,0 +1,16 @@
/**
* @param {import("../../domain/models/resource.js").Resource} resource
* @param {(value: Date) => string} [formatDate]
*/
export function toResourceViewModel(
resource,
formatDate = (value) => new Intl.DateTimeFormat("ko-KR").format(value),
) {
return Object.freeze({
resourceId: resource.id,
title: resource.displayName,
createdAtLabel: resource.createdAt
? formatDate(new Date(resource.createdAt))
: null,
});
}