add service and controller functions to update post

This commit is contained in:
Eduardo Quiros 2022-08-30 05:56:59 -06:00
parent 0ed28237aa
commit b840ebe654
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
2 changed files with 26 additions and 6 deletions

View File

@ -529,6 +529,16 @@ export class AppController {
return this.appService.createPost(post, date_entry, user_id, community_id); return this.appService.createPost(post, date_entry, user_id, community_id);
} }
@Put('post/updatePost/:id')
updatePost(
@Param('id') id: string,
@Body('post') post: string,
@Body('user_id') user_id: string,
@Body('community_id') community_id: string,
) {
return this.appService.updatePost(id, post, user_id, community_id);
}
@Get('post/allPosts') @Get('post/allPosts')
allPosts() { allPosts() {
return this.appService.allPosts(); return this.appService.allPosts();

View File

@ -638,6 +638,16 @@ export class AppService {
.pipe(map((message: string) => ({ message }))); .pipe(map((message: string) => ({ message })));
} }
updatePost(id: string, post: string, user_id: string, community_id: string) {
const pattern = { cmd: 'updatePost' };
const payload = {
post: post, id: id, user_id: user_id, community_id: community_id
};
return this.clientPostApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
allPosts() { allPosts() {
const pattern = { cmd: 'findAllPosts' }; const pattern = { cmd: 'findAllPosts' };
const payload = {}; const payload = {};