Categorygithub.com/QuickCrafts/PerfectPick_Likes_ms
modulepackage
0.0.0-20240504194620-6d8d2c6b7514
Repository: https://github.com/quickcrafts/perfectpick_likes_ms.git
Documentation: pkg.go.dev

# 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}
ParameterTypeDescription
idintRequired. media id
Query ParameterTypeDescription
media_typeenum('MOV', 'SON' , 'BOO')Required. media type
Response StatusTypeDescription
204successNo content
400error"Media id not provided"
400error"Media type not provided"
500errorAny other error message

Delete user

Delete user's node (instance) given a user id.

  DELETE /likes/user/${id}
ParameterTypeDescription
idintRequired. user id
Response StatusTypeDescription
204successNo content
400error"User id not provided"
500errorAny 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 StatusTypeDescription
201success"Relation created"
400error"Guard failed"
500errorAny other error message

Delete Like

Delete like/dislike relation.

  DELETE /likes
Query ParameterTypeDescription
user_idintRequired. user id
media_idintRequired. media id
media_typeenum('MOV', 'SON' , 'BOO')Required. media type
Response StatusTypeDescription
204successNo content
400error"User id not provided"
400error"Media id not provided"
400error"Media type not provided"
404error"Relation not found"
500errorAny other error message

Get User Likes

Returns all the like/dislikes relations make by a given user.

  GET /likes/user/${id}
ParameterTypeDescription
idintRequired. user id
Response StatusTypeDescription
200success"Returns all the user likes relations
400error"User id not provided"
404error"User not found"
500errorAny 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}
ParameterTypeDescription
idintRequired. media id
Query ParameterTypeDescription
media_typeenum('MOV', 'SON' , 'BOO')Required. media type
Response StatusTypeDescription
200success"Returns all the media likes
400error"Media id not provided"
400error"Media type not provided"
404error"Media not found"
500errorAny 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 ParameterTypeDescription
media_typeenum('MOV', 'SON' , 'BOO')Required. media type
Response StatusTypeDescription
200successReturns media average
400error"Media id not provided"
400error"Media type not provided"
500errorAny 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}
ParameterTypeDescription
idintRequired. user id
Response StatusTypeDescription
200success"Returns the user wishlist
400error"User id not provided"
404error"User not found"
500errorAny 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