Likes in VideoHub are toggle-based — calling a toggle endpoint when the authenticated user has already liked the target resource removes the like (unlike), and calling it when no like exists creates one. There is no separate “like” and “unlike” endpoint; oneDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/barcode8/VideoHub/llms.txt
Use this file to discover all available pages before exploring further.
POST handles both transitions and returns the resulting state. All endpoints require a valid JWT in the Authorization header.
Each toggle works by first searching for an existing Like document matching the resource ID and the authenticated user’s likedBy field. If a record is found it is deleted (unlike); if no record is found a new one is created (like). This findOne + delete-or-create pattern is used for all three toggle endpoints.
POST /api/v1/likes/toggle/v/:videoId
Toggles the like state of a video for the currently authenticated user. If the user has already liked the video the like record is deleted andisLiked: false is returned. If no like exists a new record is created and isLiked: true is returned.
Path parameters
The MongoDB ObjectId of the video to like or unlike. Returns
400 if missing or not a valid ObjectId.Response
true if the user has just liked the video; false if the like was removed.Example
POST /api/v1/likes/toggle/c/:commentId
Toggles the like state of a comment for the currently authenticated user. The behaviour is identical to video likes: one call either creates or deletes the like record and returns the current state.Path parameters
The MongoDB ObjectId of the comment to like or unlike. Returns
400 if missing or not a valid ObjectId.Response
true if the user has just liked the comment; false if the like was removed.Example
POST /api/v1/likes/toggle/t/:tweetId
Toggles the like state of a community post for the currently authenticated user. The URL path uses the parameter nametweetId, but internally the Like document stores the reference in the community field (not a tweet field) — the Like model uses community as the field name for all community post likes.
Path parameters
The MongoDB ObjectId of the community post to like or unlike. Stored as the
community field in the Like document. Returns 400 if missing or not a valid ObjectId.Response
true if the user has just liked the community post; false if the like was removed.Example
GET /api/v1/likes/videos
Returns an array of all videos that the currently authenticated user has liked, sorted by most recently liked first. Each entry is a flattened video document that includes the video owner’s public profile. The aggregation pipeline matches Like documents wherelikedBy equals the current user and the video field exists and is non-null, then performs a $lookup on the videos collection with a nested $lookup on users for owner details.
Parameters
No path, query, or body parameters. The user identity is derived from the JWT.Response
Returns an array of video objects. An empty array is returned if the user has not liked any videos.MongoDB ObjectId of the liked video.
Title of the video.
URL of the video’s thumbnail image.
Duration of the video in seconds.
Total view count of the video.
Public profile of the video’s uploader.
ISO 8601 timestamp of when the like was created (i.e. when the user liked the video). Used for sort order.
Example
Like object schema
The Like document stored in MongoDB is a sparse record — only the field corresponding to the liked resource type (video, comment, or community) is set; the others are left undefined. No fields carry a required constraint at the database level; all uniqueness and presence enforcement happens in the application layer.
MongoDB-generated unique identifier for the like record.
Reference to the liked
Video document. Present only for video likes.Reference to the liked
Comment document. Present only for comment likes.Reference to the liked
Community post document. Present only for community post likes. Note: the toggle endpoint for community posts uses the URL parameter name tweetId, but this is the actual database field name.Reference to the
User document who created the like.Automatically set by Mongoose
timestamps on document creation.Automatically updated by Mongoose
timestamps on every save.