2024-06-22 09:29:53 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
2024-07-16 08:53:40 +00:00
|
|
|
func MapAPIs(app *fiber.App, baseURL string) {
|
|
|
|
api := app.Group(baseURL).Name("API")
|
2024-06-22 09:29:53 +00:00
|
|
|
{
|
|
|
|
api.Get("/users/me", getUserinfo)
|
|
|
|
api.Get("/users/:accountId", getOthersInfo)
|
|
|
|
|
2024-07-23 08:12:19 +00:00
|
|
|
recommendations := api.Group("/recommendations").Name("Recommendations API")
|
|
|
|
{
|
|
|
|
recommendations.Get("/", listRecommendationDefault)
|
|
|
|
recommendations.Get("/shuffle", listRecommendationShuffle)
|
|
|
|
}
|
|
|
|
|
2024-07-21 16:49:36 +00:00
|
|
|
stories := api.Group("/stories").Name("Story API")
|
|
|
|
{
|
|
|
|
stories.Post("/", createStory)
|
|
|
|
stories.Put("/:postId", editStory)
|
|
|
|
}
|
|
|
|
articles := api.Group("/articles").Name("Article API")
|
|
|
|
{
|
|
|
|
articles.Post("/", createArticle)
|
|
|
|
articles.Put("/:articleId", editArticle)
|
|
|
|
}
|
|
|
|
|
2024-06-22 09:29:53 +00:00
|
|
|
posts := api.Group("/posts").Name("Posts API")
|
|
|
|
{
|
|
|
|
posts.Get("/", listPost)
|
2024-07-22 05:41:35 +00:00
|
|
|
posts.Get("/drafts", listDraftPost)
|
2024-07-21 16:49:36 +00:00
|
|
|
posts.Get("/:postId", getPost)
|
|
|
|
posts.Post("/:postId/react", reactPost)
|
2024-06-22 09:29:53 +00:00
|
|
|
posts.Delete("/:postId", deletePost)
|
|
|
|
|
2024-07-03 14:16:23 +00:00
|
|
|
posts.Get("/:post/replies", listPostReplies)
|
|
|
|
}
|
|
|
|
|
2024-06-22 09:29:53 +00:00
|
|
|
api.Get("/categories", listCategories)
|
|
|
|
api.Post("/categories", newCategory)
|
|
|
|
api.Put("/categories/:categoryId", editCategory)
|
|
|
|
api.Delete("/categories/:categoryId", deleteCategory)
|
|
|
|
}
|
|
|
|
}
|