-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added(#1): BaseDto, BaseModelDto, and SimplePaginatorDto
- Loading branch information
Showing
17 changed files
with
435 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { StaticDto } from '../types.js' | ||
|
||
export default class BaseDto { | ||
/** | ||
* Creates an array of DTO objects from an array of source objects. | ||
* | ||
* @template SourceObject - The type of the source objects. | ||
* @template Dto - The type of the DTO objects. | ||
* @param {StaticDto<SourceObject, Dto>} this - The static DTO class. | ||
* @param {SourceObject[]} sources - The array of source objects. | ||
* @return {Dto[]} An array of DTO objects. | ||
*/ | ||
static fromArray<SourceObject, Dto extends BaseDto>( | ||
this: StaticDto<SourceObject, Dto>, | ||
sources: SourceObject[] | ||
) { | ||
if (!sources) return [] | ||
return sources.map((source) => new this(source)) | ||
} | ||
} |
Oops, something went wrong.