2024-06-22 17:29:53 +08:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
2024-07-16 16:53:40 +08:00
|
|
|
func MapAPIs(app *fiber.App, baseURL string) {
|
|
|
|
api := app.Group(baseURL).Name("API")
|
2024-06-22 17:29:53 +08:00
|
|
|
{
|
|
|
|
api.Get("/users/me", getUserinfo)
|
2024-07-25 22:45:31 +08:00
|
|
|
api.Get("/users/:account", getOthersInfo)
|
2024-07-25 22:58:47 +08:00
|
|
|
api.Get("/users/:account/pin", listOthersPinnedPost)
|
2024-06-22 17:29:53 +08:00
|
|
|
|
2024-08-19 00:57:20 +08:00
|
|
|
api.Get("/publishers/:name", getPublisher)
|
|
|
|
|
2024-07-23 16:12:19 +08:00
|
|
|
recommendations := api.Group("/recommendations").Name("Recommendations API")
|
|
|
|
{
|
2024-07-28 01:49:16 +08:00
|
|
|
recommendations.Get("/", listRecommendationNews)
|
2024-08-19 00:04:49 +08:00
|
|
|
recommendations.Get("/friends", listRecommendationFriends)
|
2024-07-23 16:12:19 +08:00
|
|
|
recommendations.Get("/shuffle", listRecommendationShuffle)
|
|
|
|
}
|
|
|
|
|
2024-07-22 00:49:36 +08: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)
|
2024-07-23 18:05:54 +08:00
|
|
|
articles.Put("/:postId", editArticle)
|
2024-07-22 00:49:36 +08:00
|
|
|
}
|
|
|
|
|
2024-06-22 17:29:53 +08:00
|
|
|
posts := api.Group("/posts").Name("Posts API")
|
|
|
|
{
|
|
|
|
posts.Get("/", listPost)
|
2024-08-10 21:11:55 +08:00
|
|
|
posts.Get("/minimal", listPostMinimal)
|
2024-07-22 13:41:35 +08:00
|
|
|
posts.Get("/drafts", listDraftPost)
|
2024-07-22 00:49:36 +08:00
|
|
|
posts.Get("/:postId", getPost)
|
|
|
|
posts.Post("/:postId/react", reactPost)
|
2024-07-25 22:45:31 +08:00
|
|
|
posts.Post("/:postId/pin", pinPost)
|
2024-06-22 17:29:53 +08:00
|
|
|
posts.Delete("/:postId", deletePost)
|
|
|
|
|
2024-07-23 17:59:11 +08:00
|
|
|
posts.Get("/:postId/replies", listPostReplies)
|
2024-07-03 22:16:23 +08:00
|
|
|
}
|
|
|
|
|
2024-06-22 17:29:53 +08:00
|
|
|
api.Get("/categories", listCategories)
|
2024-07-31 01:25:51 +08:00
|
|
|
api.Get("/categories/:category", getCategory)
|
2024-06-22 17:29:53 +08:00
|
|
|
api.Post("/categories", newCategory)
|
|
|
|
api.Put("/categories/:categoryId", editCategory)
|
|
|
|
api.Delete("/categories/:categoryId", deleteCategory)
|
2024-07-31 01:25:51 +08:00
|
|
|
|
|
|
|
api.Get("/tags", listTags)
|
|
|
|
api.Get("/tags/:tag", getTag)
|
2024-06-22 17:29:53 +08:00
|
|
|
}
|
|
|
|
}
|