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)
|
|
|
|
|
|
|
|
api.Get("/feed", listFeed)
|
|
|
|
|
2024-07-03 14:16:23 +00:00
|
|
|
drafts := api.Group("/drafts").Name("Draft box API")
|
|
|
|
{
|
2024-07-09 13:07:46 +00:00
|
|
|
drafts.Get("/", listDraftMixed)
|
2024-07-03 14:16:23 +00:00
|
|
|
drafts.Get("/posts", listDraftPost)
|
|
|
|
drafts.Get("/articles", listDraftArticle)
|
|
|
|
}
|
|
|
|
|
2024-06-22 09:29:53 +00:00
|
|
|
posts := api.Group("/posts").Name("Posts API")
|
|
|
|
{
|
|
|
|
posts.Get("/", listPost)
|
|
|
|
posts.Get("/:post", getPost)
|
|
|
|
posts.Post("/", createPost)
|
|
|
|
posts.Post("/:post/react", reactPost)
|
|
|
|
posts.Put("/:postId", editPost)
|
|
|
|
posts.Delete("/:postId", deletePost)
|
|
|
|
|
2024-07-03 14:16:23 +00:00
|
|
|
posts.Get("/:post/replies", listPostReplies)
|
|
|
|
}
|
|
|
|
|
|
|
|
articles := api.Group("/articles").Name("Articles API")
|
|
|
|
{
|
|
|
|
articles.Get("/", listArticle)
|
|
|
|
articles.Get("/:article", getArticle)
|
|
|
|
articles.Post("/", createArticle)
|
|
|
|
articles.Post("/:article/react", reactArticle)
|
|
|
|
articles.Put("/:articleId", editArticle)
|
|
|
|
articles.Delete("/:articleId", deleteArticle)
|
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)
|
|
|
|
}
|
|
|
|
}
|