replace file with url when sending post to client
This commit is contained in:
parent
b3cdc9f518
commit
6b79e36c98
|
|
@ -31,6 +31,7 @@ const getAllPosts = async (): Promise<PrismaPost[]> => {
|
|||
});
|
||||
return (await posts).map((post) => {
|
||||
post.author = exclude(post.author, 'password');
|
||||
post.image = post.image ? `/uploads/${post.image}` : null;
|
||||
return post;
|
||||
});
|
||||
};
|
||||
|
|
@ -43,6 +44,7 @@ const createPost = async (post: Post): Promise<PrismaPost> => {
|
|||
image: post.image,
|
||||
},
|
||||
});
|
||||
newPost.image = newPost.image ? `/uploads/${newPost.image}` : null;
|
||||
|
||||
return newPost;
|
||||
};
|
||||
|
|
@ -72,6 +74,8 @@ const editPost = async (post: Post): Promise<PrismaPost | null | Error> => {
|
|||
return null;
|
||||
}
|
||||
|
||||
editedPost.image = editedPost.image ? `/uploads/${editedPost.image}` : null;
|
||||
|
||||
return editedPost;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue