Paperclip/pkg/internal/server/api/index.go

70 lines
2.2 KiB
Go
Raw Normal View History

package api
2024-10-27 05:13:40 +00:00
import (
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
)
2024-07-16 09:02:16 +00:00
func MapAPIs(app *fiber.App, baseURL string) {
api := app.Group(baseURL).Name("API")
{
2024-12-28 14:27:39 +00:00
api.Get("/destinations", listDestination)
2024-12-28 13:41:13 +00:00
boost := api.Group("/boosts").Name("Boosts API")
{
2024-12-28 14:14:30 +00:00
boost.Get("/", listBoostByUser)
2024-12-28 13:41:13 +00:00
boost.Get("/:id", getBoost)
boost.Post("/", sec.ValidatorMiddleware, createBoost)
boost.Put("/:id", sec.ValidatorMiddleware, updateBoost)
}
2024-12-28 14:04:48 +00:00
pools := api.Get("/pools").Name("Pools API")
{
pools.Get("/", listPool)
pools.Get("/:id", getPool)
pools.Post("/", sec.ValidatorMiddleware, createPool)
pools.Put("/:id", sec.ValidatorMiddleware, updatePool)
pools.Delete("/:id", sec.ValidatorMiddleware, deletePool)
}
attachments := api.Get("/attachments").Name("Attachments API")
{
2024-12-28 14:14:30 +00:00
attachments.Get("/:attachmentId/boosts", listBoostByAttachment)
2024-12-28 14:08:45 +00:00
2024-12-28 14:04:48 +00:00
attachments.Get("/", listAttachment)
attachments.Get("/:id/meta", getAttachmentMeta)
attachments.Get("/:id", openAttachment)
attachments.Post("/", sec.ValidatorMiddleware, createAttachmentDirectly)
attachments.Put("/:id", sec.ValidatorMiddleware, updateAttachmentMeta)
attachments.Delete("/:id", sec.ValidatorMiddleware, deleteAttachment)
}
fragments := api.Get("/fragments").Name("Fragments API")
{
fragments.Post("/", sec.ValidatorMiddleware, createAttachmentFragment)
fragments.Post("/:file/:chunk", sec.ValidatorMiddleware, uploadFragmentChunk)
}
stickers := api.Get("/stickers").Name("Stickers API")
{
stickers.Get("/lookup", lookupStickerBatch)
stickers.Get("/lookup/:alias", lookupSticker)
stickers.Get("/", listStickers)
stickers.Get("/:stickerId", getSticker)
stickers.Post("/", sec.ValidatorMiddleware, createSticker)
stickers.Put("/:stickerId", sec.ValidatorMiddleware, updateSticker)
stickers.Delete("/:stickerId", sec.ValidatorMiddleware, deleteSticker)
packs := stickers.Group("/packs").Name("Sticker Packs API")
{
packs.Get("/", listStickerPacks)
packs.Get("/:packId", getStickerPack)
packs.Post("/", sec.ValidatorMiddleware, createStickerPack)
packs.Put("/:packId", sec.ValidatorMiddleware, updateStickerPack)
packs.Delete("/:packId", sec.ValidatorMiddleware, deleteStickerPack)
}
}
}
}