2022-05-04 07:27:16 -07:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
2023-03-16 04:49:27 -07:00
|
|
|
"os"
|
|
|
|
|
2022-05-14 07:52:08 -07:00
|
|
|
"codeberg.org/u1f320/pronouns.cc/backend/server"
|
2022-05-04 07:27:16 -07:00
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Server struct {
|
|
|
|
*server.Server
|
2023-03-16 04:49:27 -07:00
|
|
|
|
|
|
|
ExporterPath string
|
2022-05-04 07:27:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func Mount(srv *server.Server, r chi.Router) {
|
2023-03-16 04:49:27 -07:00
|
|
|
s := &Server{
|
|
|
|
Server: srv,
|
|
|
|
ExporterPath: "http://127.0.0.1:" + os.Getenv("EXPORTER_PORT"),
|
|
|
|
}
|
2022-05-04 07:27:16 -07:00
|
|
|
|
|
|
|
r.Route("/users", func(r chi.Router) {
|
|
|
|
r.Get("/{userRef}", server.WrapHandler(s.getUser))
|
2022-05-17 13:35:26 -07:00
|
|
|
|
|
|
|
r.With(server.MustAuth).Group(func(r chi.Router) {
|
|
|
|
r.Get("/@me", server.WrapHandler(s.getMeUser))
|
2022-06-16 05:54:15 -07:00
|
|
|
r.Patch("/@me", server.WrapHandler(s.patchUser))
|
2023-03-08 01:32:18 -08:00
|
|
|
r.Delete("/@me", server.WrapHandler(s.deleteUser))
|
2023-03-16 04:49:27 -07:00
|
|
|
|
2023-03-16 09:49:40 -07:00
|
|
|
r.Get("/@me/export/start", server.WrapHandler(s.startExport))
|
|
|
|
r.Get("/@me/export", server.WrapHandler(s.getExport))
|
2023-05-09 15:45:31 -07:00
|
|
|
|
|
|
|
r.Get("/@me/flags", server.WrapHandler(s.getUserFlags))
|
|
|
|
r.Post("/@me/flags", server.WrapHandler(s.postUserFlag))
|
2023-05-26 06:22:27 -07:00
|
|
|
r.Patch("/@me/flags/{flagID}", server.WrapHandler(s.patchUserFlag))
|
2023-05-28 07:19:42 -07:00
|
|
|
r.Delete("/@me/flags/{flagID}", server.WrapHandler(s.deleteUserFlag))
|
2022-05-17 13:35:26 -07:00
|
|
|
})
|
2022-05-04 07:27:16 -07:00
|
|
|
})
|
|
|
|
}
|