33 lines
714 B
Go
Raw Normal View History

2024-12-14 12:40:29 +08:00
package api
import (
2025-01-25 22:08:36 +08:00
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
2025-01-25 23:54:50 +08:00
"git.solsynth.dev/hypernet/reader/pkg/internal/services"
2024-12-14 12:40:29 +08:00
"github.com/gofiber/fiber/v2"
)
func MapAPIs(app *fiber.App, baseURL string) {
api := app.Group(baseURL).Name("API")
{
2025-01-25 22:15:35 +08:00
api.Get("/well-known/sources", getNewsSources)
2025-01-25 22:08:36 +08:00
admin := api.Group("/admin").Name("Admin")
{
2025-01-25 23:54:50 +08:00
admin.Get("/scan", func(c *fiber.Ctx) error {
services.ScanNewsSources()
return c.SendStatus(fiber.StatusOK)
})
2025-01-25 22:08:36 +08:00
admin.Post("/scan", sec.ValidatorMiddleware, adminTriggerScanTask)
}
2024-12-14 12:40:29 +08:00
api.Get("/link/*", getLinkMeta)
2025-01-25 22:15:35 +08:00
news := api.Group("/news").Name("News")
{
news.Get("/", listNewsArticles)
news.Get("/:hash", getNewsArticle)
}
2024-12-14 12:40:29 +08:00
}
}