# README
Likes Microservice
Management of likes and dislikes relation between users and media (movie, books, music).
API Reference
Instance Management
Delete Media
Delete media's node (instance) given a media id and media type.
DELETE /likes/media/${id}
Parameter | Type | Description |
---|---|---|
id | int | Required. media id |
Query Parameter | Type | Description |
---|---|---|
media_type | enum('MOV', 'SON' , 'BOO') | Required. media type |
Response Status | Type | Description |
---|---|---|
204 | success | No content |
400 | error | "Media id not provided" |
400 | error | "Media type not provided" |
500 | error | Any other error message |
Delete user
Delete user's node (instance) given a user id.
DELETE /likes/user/${id}
Parameter | Type | Description |
---|---|---|
id | int | Required. user id |
Response Status | Type | Description |
---|---|---|
204 | success | No content |
400 | error | "User id not provided" |
500 | error | Any other error message |
Likes Management
Create Like
Create new like/dislike relation.
POST /likes
// Body interface
interface Create_Like{
user_id: number
media_id: number
media_type: 'MOV' | 'BOO' | 'SON'
like_type: 'LK' | 'DLK'
rating?: float
wishlist?: boolean
}
Response Status | Type | Description |
---|---|---|
201 | success | "Relation created" |
400 | error | "Guard failed" |
500 | error | Any other error message |
Delete Like
Delete like/dislike relation.
DELETE /likes
Query Parameter | Type | Description |
---|---|---|
user_id | int | Required. user id |
media_id | int | Required. media id |
media_type | enum('MOV', 'SON' , 'BOO') | Required. media type |
Response Status | Type | Description |
---|---|---|
204 | success | No content |
400 | error | "User id not provided" |
400 | error | "Media id not provided" |
400 | error | "Media type not provided" |
404 | error | "Relation not found" |
500 | error | Any other error message |
Get User Likes
Returns all the like/dislikes relations make by a given user.
GET /likes/user/${id}
Parameter | Type | Description |
---|---|---|
id | int | Required. user id |
Response Status | Type | Description |
---|---|---|
200 | success | "Returns all the user likes relations |
400 | error | "User id not provided" |
404 | error | "User not found" |
500 | error | Any other error message |
interface Like_Relation{
id: int // Media id
user_id: int
type: 'MOV' | 'BOO' | 'SON' // Media type
rating?: float // given by the user searched
like_type: 'LK' | 'DLK' | 'BLK' // Liked | Disliked | Blank (no info yet)
wishlist: boolean // Inside user wishlist? Yes or No
}
// Body interface
interface Get_Likes{
id: number // User id
movies: Like_Relation[]
books: Like_Relation[]
songs: Like_Relation[]
}
Get Media Likes
Returns all the like/dislikes relations of a given media id (book, movie, song).
GET /likes/media/${id}
Parameter | Type | Description |
---|---|---|
id | int | Required. media id |
Query Parameter | Type | Description |
---|---|---|
media_type | enum('MOV', 'SON' , 'BOO') | Required. media type |
Response Status | Type | Description |
---|---|---|
200 | success | "Returns all the media likes |
400 | error | "Media id not provided" |
400 | error | "Media type not provided" |
404 | error | "Media not found" |
500 | error | Any other error message |
interface Like_Relation{
id: number // Media id
user_id: number
type: 'MOV' | 'BOO' | 'SON' // Media type
rating?: float // given by the user searched
like_type: 'LK' | 'DLK' | 'BLK' // Liked | Disliked | Blank (no info yet)
wishlist: boolean // Inside user wishlist? Yes or No
}
// Body interface
interface Get_Likes_Media{
likes: Like_Relation[]
avg_rating: float
}
Get Rating
Get average rating of a media.
GET /likes/average/${id}
Query Parameter | Type | Description |
---|---|---|
media_type | enum('MOV', 'SON' , 'BOO') | Required. media type |
Response Status | Type | Description |
---|---|---|
200 | success | Returns media average |
400 | error | "Media id not provided" |
400 | error | "Media type not provided" |
500 | error | Any other error message |
// Body interface
interface Get_Likes_Media{
id: number // Media id
type: 'MOV' | 'SON' | 'BOO' // Media Type
avg_rating: float
}
Wishlist
Get media on Wishlist
Get wishlist of a given user divided by media type.
GET /likes/wishlist/${id}
Parameter | Type | Description |
---|---|---|
id | int | Required. user id |
Response Status | Type | Description |
---|---|---|
200 | success | "Returns the user wishlist |
400 | error | "User id not provided" |
404 | error | "User not found" |
500 | error | Any other error message |
// Body interface
interface Get_Likes{
id: number // User id
movies: number[] // Wishlist movie ids
books: number[] // Wishlist book ids
songs: number[] // Wishlist song ids
}
Deployment
To deploy this project:
Deploy database
./run_DB.sh
Deploy API
./run_API.sh
Call API using (http://localhost:3000)[http://localhost:3000]
Run Locally
Clone the project
git clone https://github.com/QuickCrafts/PerfectPick_Likes_ms.git
Go to the project directory
cd PerfectPick_Likes_ms
Open Database
./run_DB.sh
Start the server
make run
Call API using (http://localhost:3000)[http://localhost:3000]
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author