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
+19
View File
@@ -0,0 +1,19 @@
/**
* @typedef {{
* id: string,
* displayName: string,
* createdAt: string | null
* }} Resource
*/
/** @param {Resource} values @returns {Readonly<Resource>} */
export function createResource(values) {
if (!values.id || !values.displayName) {
throw new TypeError("Resource invariants require id and displayName");
}
return Object.freeze({
id: values.id,
displayName: values.displayName,
createdAt: values.createdAt,
});
}