Structure: This project conatains two application:
- server app (inside of './server' folder)
- client app (inside of './client' folder)
Task related to client app. So, everything what you have to do you will do it inside of './client' folder
Steps:
- Download and install node here - https://nodejs.org/en/ (if needed)
- Open project using VSC or some other code editor
- Run command in terminal (inside of this folder): npm run setup (it should install all dependencies)
- Run commant in terminal (inside of this folder): npm run start_server (it should start server app)
- Open additional terminal and run command: npm run start_client (it should start client app)
API Client app should use api provided by server app. Here is endpoints description:
MAIN_URL = http://localhost:8080/
CREATE POST: url: MAIN_URL + 'post/' method: post body: { title: , username: } response: { id: , title: , username: likes: <Array> //usernames dislikes: <Array> //usernames imageSrc: //path date: , comments: <Array> }
UPDATE POST url: MAIN_URL + 'post/{id}' method: put body: { title?: , likes?: Array<>, dislikes?: Array<> } response: { id: , title: , username: likes: <Array> dislikes: <Array> date: , comments: <Array> }
FILTER/SEARCH POSTS BY KEYWORD url MAIN_URL + 'post/search/${keyWord}' method: get response: [ { id: , title: , username: likes: <Array> //usernames dislikes: <Array> //usernames imageSrc: //path date: , comments: <Array> } ... ]
GET POSTS BY PAGES (9 posts per page) url MAIN_URL + 'post/page/${pageNumber}' // pageNumber > 0 response: [ { id: , title: , username: likes: <Array> //usernames dislikes: <Array> //usernames imageSrc: //path date: , comments: <Array> } ... ]
- response conains additional information: totalPages, total and page
DELETE POST url: MAIN_URL + 'post/{id}' method: delete response: { id: , title: , username: likes: <Array> //usernames dislikes: <Array> //usernames imageSrc: //path date: , comments: <Array> }
UPLOAD POST PICTURE url: MAIN_URL + 'post/{id}/picture' method: post body: FormData // should contain file like this formData.append("picture", file); response: { id: , title: , username: likes: <Array> //usernames dislikes: <Array> //usernames imageSrc: //path date: , comments: <Array> }
CREATE COMMENT url: MAIN_URL + 'comment' method: post body: { text: , postId: , username: , } response: { id: , text: , postId: , username: , likes: <Array>, dislikes: <Array>, date: }
UPDATE COMMENT url: MAIN_URL + 'comment/{id}' method: put body: { text: , likes: <Array>, dislikes: <Array>, } response: { id: , text: , postId: , username: , likes: <Array>, dislikes: <Array>, date: }
DELETE COMMENT url: MAIN_URL + 'comment/{id}' method: delete response: { id: , text: , postId: , username: , likes: <Array>, dislikes: <Array>, date: }
=============== i hope next endpoints will shouldn't be used, but i'll left it here, just in case ====================
GET ALL POSTS url: MAIN_URL + 'post' method: get response: [ { id: , title: , username: likes: <Array> //usernames dislikes: <Array> //usernames imageSrc: //path date: , comments: <Array> } ... ]
GET POST url: MAIN_URL + 'post/{id}' method: get response: { id: , title: , username: likes: <Array> //usernames dislikes: <Array> //usernames imageSrc: //path date: , comments: <Array> }
GET COMMENT url: MAIN_URL + 'comment/{id}' method: get response: { id: , text: , postId: , username: , likes: <Array>, dislikes: <Array>, date: }
GET COMMENTS url: MAIN_URL + 'comment' method: get response: [ { id: , text: , postId: , username: , likes: <Array>, dislikes: <Array>, date: }, ... ]