Skip to content

Commit de3af37

Browse files
committed
Refactor response mappers to standardize currentUserId type handling
This commit updates the response mappers in the articles and comments modules by changing the type of `currentUserId` from `string | null` to `string`. This change enhances code consistency and clarity across the mappers, ensuring a more uniform handling of user ID values.
1 parent 5221e12 commit de3af37

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/articles/mappers/to-articles-response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { ArticlesResponse, EnrichedArticle } from "../interfaces";
88
*/
99
export function toArticlesResponse(
1010
enrichedArticles: EnrichedArticle[],
11-
{ currentUserId }: { currentUserId?: string | null } = {},
11+
{ currentUserId }: { currentUserId?: string } = {},
1212
): ArticlesResponse {
1313
const myArticles = enrichedArticles.map((article) => {
1414
const myFavorites =

src/articles/mappers/to-response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type ToResponseParams = {
55
* The ID of the current user
66
* If provided, the article will be enriched with the current user's information, including article favorites and author following
77
*/
8-
currentUserId?: string | null;
8+
currentUserId?: string;
99
};
1010

1111
/**

src/comments/mappers/to-response.mapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { EnrichedComment } from "../interfaces";
99
*/
1010
export function toCommentResponse(
1111
enrichedComment: EnrichedComment,
12-
{ currentUserId }: { currentUserId?: string | null } = {},
12+
{ currentUserId }: { currentUserId?: string } = {},
1313
): {
1414
comment: {
1515
id: string;
@@ -53,7 +53,7 @@ export function toCommentResponse(
5353
*/
5454
export function toCommentsResponse(
5555
enrichedComments: EnrichedComment[],
56-
{ currentUserId }: { currentUserId?: string | null } = {},
56+
{ currentUserId }: { currentUserId?: string } = {},
5757
): {
5858
comments: Array<{
5959
id: string;

0 commit comments

Comments
 (0)