routes

package
v0.0.0-...-6a61234 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSONBody

func DecodeJSONBody(c *fiber.Ctx, dst interface{}) (int, *utils.ErrorResponse)

func HealthCheck

func HealthCheck(c *fiber.Ctx) error

@Summary HealthCheck @Description This endpoint checks the health of our application. @Tags HealthCheck @Success 200 {object} HealthCheckSchema @Router /healthcheck [get]

func PaginateQueryset

func PaginateQueryset(queryset interface{}, fiberCtx *fiber.Ctx, opts ...int) (*schemas.PaginatedResponseDataSchema, *interface{}, *utils.ErrorResponse)

func SendMessageDeletionInSocket

func SendMessageDeletionInSocket(fiberCtx *fiber.Ctx, chatID uuid.UUID, messageID uuid.UUID) error

func SendNotificationInSocket

func SendNotificationInSocket(fiberCtx *fiber.Ctx, notification *ent.Notification, commentSlug *string, replySlug *string, statusOpts ...string) error

func SetupRoutes

func SetupRoutes(app *fiber.App, db *ent.Client)

All Endpoints (50)

func SetupSockets

func SetupSockets(app *fiber.App)

func ValidateReactionFocus

func ValidateReactionFocus(focus string) *utils.ErrorResponse

Types

type Endpoint

type Endpoint struct {
	DB *ent.Client
}

func (Endpoint) AcceptOrRejectFriendRequest

func (endpoint Endpoint) AcceptOrRejectFriendRequest(c *fiber.Ctx) error

@Summary Accept Or Reject a Friend Request @Description This endpoint accepts or reject a friend request @Tags Profiles @Param friend_request body schemas.AcceptFriendRequestSchema true "Friend Request object" @Success 200 {object} schemas.ResponseSchema @Router /profiles/friends/requests [put] @Security BearerAuth

func (Endpoint) CreateComment

func (endpoint Endpoint) CreateComment(c *fiber.Ctx) error

@Summary Create Comment @Description This endpoint creates a new comment for a particular post @Tags Feed @Param slug path string true "Post Slug" @Param comment body schemas.CommentInputSchema true "Comment object" @Success 201 {object} schemas.CommentResponseSchema @Router /feed/posts/{slug}/comments [post] @Security BearerAuth

func (Endpoint) CreateGroupChat

func (endpoint Endpoint) CreateGroupChat(c *fiber.Ctx) error

@Summary Create a Group Chat @Description `This endpoint creates a group chat.` @Description @Description `The users_entry field should be a list of usernames you want to add to the group.` @Description @Description `Note: You cannot add more than 99 users in a group (1 owner + 99 other users = 100 users total).` @Tags Chat @Param chat body schemas.GroupChatCreateSchema true "Chat object" @Success 201 {object} schemas.GroupChatInputResponseSchema @Router /chats/groups/group [post] @Security BearerAuth

func (Endpoint) CreatePost

func (endpoint Endpoint) CreatePost(c *fiber.Ctx) error

@Summary Create Post @Description This endpoint creates a new post @Tags Feed @Param post body schemas.PostInputSchema true "Post object" @Success 201 {object} schemas.PostInputResponseSchema @Router /feed/posts [post] @Security BearerAuth

func (Endpoint) CreateReaction

func (endpoint Endpoint) CreateReaction(c *fiber.Ctx) error

@Summary Create Reaction @Description This endpoint creates a new reaction. @Tags Feed @Param focus path string true "Specify the usage. Use any of the three: POST, COMMENT, REPLY" @Param slug path string true "Enter the slug of the post or comment or reply" @Param post body schemas.ReactionInputSchema true "Reaction object. rtype should be any of these: LIKE, LOVE, HAHA, WOW, SAD, ANGRY" @Success 201 {object} schemas.ReactionResponseSchema @Router /feed/reactions/{focus}/{slug} [post] @Security BearerAuth

func (Endpoint) CreateReply

func (endpoint Endpoint) CreateReply(c *fiber.Ctx) error

@Summary Create Reply @Description This endpoint creates a reply for a comment @Tags Feed @Param slug path string true "Comment Slug" @Param reply body schemas.CommentInputSchema true "Reply object" @Success 201 {object} schemas.ReplyResponseSchema @Router /feed/comments/{slug} [post] @Security BearerAuth

func (Endpoint) DeleteComment

func (endpoint Endpoint) DeleteComment(c *fiber.Ctx) error

@Summary Delete Comment @Description This endpoint deletes a comment @Tags Feed @Param slug path string true "Comment Slug" @Success 200 {object} schemas.ResponseSchema @Router /feed/comments/{slug} [delete] @Security BearerAuth

func (Endpoint) DeleteGroupChat

func (endpoint Endpoint) DeleteGroupChat(c *fiber.Ctx) error

@Summary Delete a Group Chat @Description `This endpoint deletes a group chat.` @Tags Chat @Param chat_id path string true "Chat ID (uuid)" @Success 200 {object} schemas.ResponseSchema @Router /chats/{chat_id} [delete] @Security BearerAuth

func (Endpoint) DeleteMessage

func (endpoint Endpoint) DeleteMessage(c *fiber.Ctx) error

@Summary Delete a message @Description `This endpoint deletes a message.` @Tags Chat @Param message_id path string true "Message ID (uuid)" @Success 200 {object} schemas.ResponseSchema @Router /chats/messages/{message_id} [delete] @Security BearerAuth

func (Endpoint) DeletePost

func (endpoint Endpoint) DeletePost(c *fiber.Ctx) error

@Summary Delete a Post @Description This endpoint deletes a post @Tags Feed @Param slug path string true "Post slug" @Success 200 {object} schemas.ResponseSchema @Router /feed/posts/{slug} [delete] @Security BearerAuth

func (Endpoint) DeleteReaction

func (endpoint Endpoint) DeleteReaction(c *fiber.Ctx) error

@Summary Remove Reaction @Description This endpoint deletes a reaction @Tags Feed @Param id path string true "Reaction id (uuid)" @Success 200 {object} schemas.ResponseSchema @Router /feed/reactions/{id} [delete] @Security BearerAuth

func (Endpoint) DeleteReply

func (endpoint Endpoint) DeleteReply(c *fiber.Ctx) error

@Summary Delete Reply @Description This endpoint deletes a reply @Tags Feed @Param slug path string true "Reply Slug" @Success 200 {object} schemas.ResponseSchema @Router /feed/replies/{slug} [delete] @Security BearerAuth

func (Endpoint) DeleteUser

func (endpoint Endpoint) DeleteUser(c *fiber.Ctx) error

@Summary Delete User's Account @Description This endpoint deletes a particular user's account (irreversible) @Tags Profiles @Param password body schemas.DeleteUserSchema true "Password" @Success 200 {object} schemas.ResponseSchema @Router /profiles/profile [post] @Security BearerAuth

func (Endpoint) GetSiteDetails

func (endpoint Endpoint) GetSiteDetails(c *fiber.Ctx) error

@Summary Retrieve site details @Description This endpoint retrieves few details of the site/application. @Tags General @Success 200 {object} schemas.SiteDetailResponseSchema @Router /general/site-detail [get]

func (Endpoint) Login

func (endpoint Endpoint) Login(c *fiber.Ctx) error

@Summary Login a user @Description This endpoint generates new access and refresh tokens for authentication @Tags Auth @Param user body schemas.LoginSchema true "User login" @Success 201 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 401 {object} utils.ErrorResponse @Security GuestUserAuth @Router /auth/login [post]

func (Endpoint) Logout

func (endpoint Endpoint) Logout(c *fiber.Ctx) error

@Summary Logout a user @Description This endpoint logs a user out from our application @Tags Auth @Success 200 {object} schemas.ResponseSchema @Failure 401 {object} utils.ErrorResponse @Router /auth/logout [get] @Security BearerAuth

func (Endpoint) ReadNotification

func (endpoint Endpoint) ReadNotification(c *fiber.Ctx) error

@Summary Read Notifications @Description This endpoint reads a notification @Tags Profiles @Param read_data body schemas.ReadNotificationSchema true "Read Notification Data" @Success 200 {object} schemas.ResponseSchema @Router /profiles/notifications [post] @Security BearerAuth

func (Endpoint) Refresh

func (endpoint Endpoint) Refresh(c *fiber.Ctx) error

@Summary Refresh tokens @Description This endpoint refresh tokens by generating new access and refresh tokens for a user @Tags Auth @Param refresh body schemas.RefreshTokenSchema true "Refresh token" @Success 201 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Failure 401 {object} utils.ErrorResponse @Router /auth/refresh [post]

func (Endpoint) Register

func (endpoint Endpoint) Register(c *fiber.Ctx) error

@Summary Register a new user @Description This endpoint registers new users into our application. @Tags Auth @Param user body schemas.RegisterUser true "User object" @Success 201 {object} schemas.RegisterResponseSchema @Failure 422 {object} utils.ErrorResponse @Router /auth/register [post]

func (Endpoint) ResendVerificationEmail

func (endpoint Endpoint) ResendVerificationEmail(c *fiber.Ctx) error

@Summary Resend Verification Email @Description This endpoint resends new otp to the user's email. @Tags Auth @Param email body schemas.EmailRequestSchema true "Email object" @Success 200 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Router /auth/resend-verification-email [post]

func (Endpoint) RetrieveCities

func (endpoint Endpoint) RetrieveCities(c *fiber.Ctx) error

@Summary Retrieve cities based on query params @Description This endpoint retrieves the first 10 cities that matches the query params @Tags Profiles @Param name query string false "City name" @Success 200 {object} schemas.CitiesResponseSchema @Router /profiles/cities [get]

func (Endpoint) RetrieveCommentWithReplies

func (endpoint Endpoint) RetrieveCommentWithReplies(c *fiber.Ctx) error

@Summary Retrieve Comment with replies @Description This endpoint retrieves a comment with replies @Tags Feed @Param slug path string true "Comment Slug" @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.CommentWithRepliesResponseSchema @Router /feed/comments/{slug} [get]

func (Endpoint) RetrieveComments

func (endpoint Endpoint) RetrieveComments(c *fiber.Ctx) error

@Summary Retrieve Post Comments @Description This endpoint retrieves comments of a particular post @Tags Feed @Param slug path string true "Post Slug" @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.CommentsResponseSchema @Router /feed/posts/{slug}/comments [get]

func (Endpoint) RetrieveFriendRequests

func (endpoint Endpoint) RetrieveFriendRequests(c *fiber.Ctx) error

@Summary Retrieve Friend Requests @Description This endpoint retrieves friend requests of a user @Tags Profiles @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.ProfilesResponseSchema @Router /profiles/friends/requests [get] @Security BearerAuth

func (Endpoint) RetrieveFriends

func (endpoint Endpoint) RetrieveFriends(c *fiber.Ctx) error

@Summary Retrieve Friends @Description This endpoint retrieves friends of a user @Tags Profiles @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.ProfilesResponseSchema @Router /profiles/friends [get] @Security BearerAuth

func (Endpoint) RetrieveMessages

func (endpoint Endpoint) RetrieveMessages(c *fiber.Ctx) error

@Summary Retrieve messages from a Chat @Description `This endpoint retrieves all messages in a chat` @Tags Chat @Param chat_id path string true "Chat ID (uuid)" @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.ChatResponseSchema @Router /chats/{chat_id} [get] @Security BearerAuth

func (Endpoint) RetrievePost

func (endpoint Endpoint) RetrievePost(c *fiber.Ctx) error

@Summary Retrieve Single Post @Description This endpoint retrieves a single post @Tags Feed @Param slug path string true "Post slug" @Success 200 {object} schemas.PostResponseSchema @Router /feed/posts/{slug} [get]

func (Endpoint) RetrievePosts

func (endpoint Endpoint) RetrievePosts(c *fiber.Ctx) error

@Summary Retrieve Latest Posts @Description This endpoint retrieves paginated responses of latest posts @Tags Feed @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.PostsResponseSchema @Router /feed/posts [get]

func (Endpoint) RetrieveReactions

func (endpoint Endpoint) RetrieveReactions(c *fiber.Ctx) error

@Summary Retrieve Latest Reactions of a Post, Comment, or Reply @Description This endpoint retrieves paginated responses of reactions of post, comment, reply @Tags Feed @Param focus path string true "Specify the usage. Use any of the three: POST, COMMENT, REPLY" @Param slug path string true "Enter the slug of the post or comment or reply" @Param page query int false "Current Page" default(1) @Param reaction_type query string false "Reaction Type. Must be any of these: LIKE, LOVE, HAHA, WOW, SAD, ANGRY" @Success 200 {object} schemas.ReactionsResponseSchema @Router /feed/reactions/{focus}/{slug} [get]

func (Endpoint) RetrieveReply

func (endpoint Endpoint) RetrieveReply(c *fiber.Ctx) error

@Summary Retrieve Reply @Description This endpoint retrieves a reply @Tags Feed @Param slug path string true "Reply Slug" @Success 200 {object} schemas.ReplyResponseSchema @Router /feed/replies/{slug} [get]

func (Endpoint) RetrieveUserChats

func (endpoint Endpoint) RetrieveUserChats(c *fiber.Ctx) error

@Summary Retrieve User Chats @Description `This endpoint retrieves a paginated list of the current user chats` @Tags Chat @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.ChatsResponseSchema @Router /chats [get] @Security BearerAuth

func (Endpoint) RetrieveUserNotifications

func (endpoint Endpoint) RetrieveUserNotifications(c *fiber.Ctx) error

@Summary Retrieve User Notifications @Description This endpoint retrieves a paginated list of auth user's notifications. Use post, comment, reply slug to navigate to the post, comment or reply. @Tags Profiles @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.NotificationsResponseSchema @Router /profiles/notifications [get] @Security BearerAuth

func (Endpoint) RetrieveUserProfile

func (endpoint Endpoint) RetrieveUserProfile(c *fiber.Ctx) error

@Summary Retrieve User Profile @Description This endpoint retrieves a user profile @Tags Profiles @Param username path string true "Username of user" @Success 200 {object} schemas.ProfileResponseSchema @Router /profiles/profile/{username} [get]

func (Endpoint) RetrieveUsers

func (endpoint Endpoint) RetrieveUsers(c *fiber.Ctx) error

@Summary Retrieve Users @Description This endpoint retrieves a paginated list of users @Tags Profiles @Param page query int false "Current Page" default(1) @Success 200 {object} schemas.ProfilesResponseSchema @Router /profiles [get] @Security BearerAuth

func (Endpoint) SendMessage

func (endpoint Endpoint) SendMessage(c *fiber.Ctx) error

@Summary Send a message @Description `This endpoint sends a message` @Description @Description `You must either send a text or a file or both.` @Description @Description `If there's no chat_id, then its a new chat and you must set username and leave chat_id` @Description @Description `If chat_id is available, then ignore username and set the correct chat_id` @Description @Description `The file_upload_data in the response is what is used for uploading the file to cloudinary from client` @Tags Chat @Param message body schemas.MessageCreateSchema true "Message object" @Success 201 {object} schemas.MessageCreateResponseSchema @Router /chats [post] @Security BearerAuth

func (Endpoint) SendOrDeleteFriendRequest

func (endpoint Endpoint) SendOrDeleteFriendRequest(c *fiber.Ctx) error

@Summary Send Or Delete Friend Request @Description This endpoint sends or delete friend requests @Tags Profiles @Param friend_request body schemas.SendFriendRequestSchema true "Friend Request object" @Success 200 {object} schemas.ResponseSchema @Router /profiles/friends/requests [post] @Security BearerAuth

func (Endpoint) SendPasswordResetOtp

func (endpoint Endpoint) SendPasswordResetOtp(c *fiber.Ctx) error

@Summary Send Password Reset Otp @Description This endpoint sends new password reset otp to the user's email. @Tags Auth @Param email body schemas.EmailRequestSchema true "Email object" @Success 200 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /auth/send-password-reset-otp [post]

func (Endpoint) SetNewPassword

func (endpoint Endpoint) SetNewPassword(c *fiber.Ctx) error

@Summary Set New Password @Description This endpoint verifies the password reset otp. @Tags Auth @Param email body schemas.SetNewPasswordSchema true "Password reset object" @Success 200 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Failure 404 {object} utils.ErrorResponse @Router /auth/set-new-password [post]

func (Endpoint) UpdateComment

func (endpoint Endpoint) UpdateComment(c *fiber.Ctx) error

@Summary Update Comment @Description This endpoint updates a comment @Tags Feed @Param slug path string true "Comment Slug" @Param comment body schemas.CommentInputSchema true "Comment object" @Success 200 {object} schemas.CommentResponseSchema @Router /feed/comments/{slug} [put] @Security BearerAuth

func (Endpoint) UpdateGroupChat

func (endpoint Endpoint) UpdateGroupChat(c *fiber.Ctx) error

@Summary Update a Group Chat @Description `This endpoint updates a group chat.` @Tags Chat @Param chat_id path string true "Chat ID (uuid)" @Param chat body schemas.GroupChatInputSchema true "Chat object" @Success 200 {object} schemas.GroupChatInputResponseSchema @Router /chats/{chat_id} [patch] @Security BearerAuth

func (Endpoint) UpdateMessage

func (endpoint Endpoint) UpdateMessage(c *fiber.Ctx) error

@Summary Update a message @Description `This endpoint updates a message.` @Description @Description `You must either send a text or a file or both.` @Description @Description `The file_upload_data in the response is what is used for uploading the file to cloudinary from client.` @Tags Chat @Param message_id path string true "Message ID (uuid)" @Param message body schemas.MessageUpdateSchema true "Message object" @Success 200 {object} schemas.MessageCreateResponseSchema @Router /chats/messages/{message_id} [put] @Security BearerAuth

func (Endpoint) UpdatePost

func (endpoint Endpoint) UpdatePost(c *fiber.Ctx) error

@Summary Update Post @Description This endpoint updates a post @Tags Feed @Param slug path string true "Post slug" @Param post body schemas.PostInputSchema true "Post object" @Success 200 {object} schemas.PostInputResponseSchema @Router /feed/posts/{slug} [put] @Security BearerAuth

func (Endpoint) UpdateProfile

func (endpoint Endpoint) UpdateProfile(c *fiber.Ctx) error

@Summary Update User Profile @Description This endpoint updates a user profile @Tags Profiles @Param profile body schemas.ProfileUpdateSchema true "Profile object" @Success 200 {object} schemas.ProfileResponseSchema @Router /profiles/profile [patch] @Security BearerAuth

func (Endpoint) UpdateReply

func (endpoint Endpoint) UpdateReply(c *fiber.Ctx) error

@Summary Update Reply @Description This endpoint updates a reply @Tags Feed @Param slug path string true "Reply Slug" @Param reply body schemas.CommentInputSchema true "Reply object" @Success 200 {object} schemas.ReplyResponseSchema @Router /feed/replies/{slug} [put] @Security BearerAuth

func (Endpoint) VerifyEmail

func (endpoint Endpoint) VerifyEmail(c *fiber.Ctx) error

@Summary Verify a user's email @Description This endpoint verifies a user's email. @Tags Auth @Param verify_email body schemas.VerifyEmailRequestSchema true "Verify Email object" @Success 200 {object} schemas.ResponseSchema @Failure 422 {object} utils.ErrorResponse @Router /auth/verify-email [post]

type HealthCheckSchema

type HealthCheckSchema struct {
	Success string `json:"success" example:"pong"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL