2022-09-20 03:55:00 -07:00
|
|
|
package member
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-chi/chi/v5"
|
2022-11-22 04:31:42 -08:00
|
|
|
|
2023-06-03 07:18:47 -07:00
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
2022-09-20 03:55:00 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
type Server struct {
|
|
|
|
*server.Server
|
|
|
|
}
|
|
|
|
|
|
|
|
func Mount(srv *server.Server, r chi.Router) {
|
|
|
|
s := &Server{Server: srv}
|
|
|
|
|
|
|
|
// member list
|
|
|
|
r.Get("/users/{userRef}/members", server.WrapHandler(s.getUserMembers))
|
|
|
|
r.With(server.MustAuth).Get("/users/@me/members", server.WrapHandler(s.getMeMembers))
|
|
|
|
|
|
|
|
// user-scoped member lookup (including custom urls)
|
|
|
|
r.Get("/users/{userRef}/members/{memberRef}", server.WrapHandler(s.getUserMember))
|
2023-05-23 07:32:02 -07:00
|
|
|
r.With(server.MustAuth).Get("/users/@me/members/{memberRef}", server.WrapHandler(s.getMeMember))
|
2022-09-20 03:55:00 -07:00
|
|
|
|
|
|
|
r.Route("/members", func(r chi.Router) {
|
|
|
|
// any member by ID
|
|
|
|
r.Get("/{memberRef}", server.WrapHandler(s.getMember))
|
|
|
|
|
|
|
|
// create, edit, and delete members
|
|
|
|
r.With(server.MustAuth).Post("/", server.WrapHandler(s.createMember))
|
2022-11-21 08:01:51 -08:00
|
|
|
r.With(server.MustAuth).Patch("/{memberRef}", server.WrapHandler(s.patchMember))
|
2022-11-22 04:31:42 -08:00
|
|
|
r.With(server.MustAuth).Delete("/{memberRef}", server.WrapHandler(s.deleteMember))
|
2023-06-02 18:06:26 -07:00
|
|
|
|
|
|
|
// reroll member SID
|
|
|
|
r.With(server.MustAuth).Get("/{memberRef}/reroll", server.WrapHandler(s.rerollMemberSID))
|
2022-09-20 03:55:00 -07:00
|
|
|
})
|
|
|
|
}
|