initial commit

This commit is contained in:
basil 2025-06-14 23:47:44 -04:00
commit d40b69f1f9
Signed by: basil
SSH key fingerprint: SHA256:y04xIFL/yqNaG9ae9Vl95vELtHfApGAIoOGLeVLP/fE
58 changed files with 7919 additions and 0 deletions

View file

@ -0,0 +1,37 @@
package routes
import (
"net/http"
"git.red-panda.pet/pandaware/house/backend/db"
"git.red-panda.pet/pandaware/house/backend/middleware"
"git.red-panda.pet/pandaware/house/backend/router"
)
func init() {
routes["GET"]["/category"] = new(CategoriesGET)
}
type categoriesResponse struct {
Categories []db.Category `json:"categories"`
}
type CategoriesGET struct{}
// Authorize implements router.AuthorizedRoute.
func (c *CategoriesGET) Authorize(ctx *router.Context) error {
return middleware.Authenticated(ctx)
}
// Handle implements router.Route.
func (c *CategoriesGET) Handle(ctx *router.Context) error {
categories, err := ctx.Query.ListCategories(ctx)
if err != nil {
return ctx.GenericError(err, http.StatusInternalServerError)
}
return ctx.JSON(200, categoriesResponse{
Categories: categories,
})
}
var _ router.AuthorizedRoute = new(CategoriesGET)