feat!(backend): move /auth/export to /users/@me/export
This commit is contained in:
parent
17f6ac4d23
commit
f087e9a29f
5 changed files with 14 additions and 9 deletions
|
@ -18,7 +18,6 @@ type Server struct {
|
||||||
|
|
||||||
RequireInvite bool
|
RequireInvite bool
|
||||||
BaseURL string
|
BaseURL string
|
||||||
ExporterPath string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type userResponse struct {
|
type userResponse struct {
|
||||||
|
@ -57,7 +56,6 @@ func Mount(srv *server.Server, r chi.Router) {
|
||||||
Server: srv,
|
Server: srv,
|
||||||
RequireInvite: os.Getenv("REQUIRE_INVITE") == "true",
|
RequireInvite: os.Getenv("REQUIRE_INVITE") == "true",
|
||||||
BaseURL: os.Getenv("BASE_URL"),
|
BaseURL: os.Getenv("BASE_URL"),
|
||||||
ExporterPath: "http://127.0.0.1:" + os.Getenv("EXPORTER_PORT"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Route("/auth", func(r chi.Router) {
|
r.Route("/auth", func(r chi.Router) {
|
||||||
|
@ -92,9 +90,6 @@ func Mount(srv *server.Server, r chi.Router) {
|
||||||
r.With(server.MustAuth).Post("/tokens", server.WrapHandler(s.createToken))
|
r.With(server.MustAuth).Post("/tokens", server.WrapHandler(s.createToken))
|
||||||
r.With(server.MustAuth).Delete("/tokens/{id}", server.WrapHandler(s.deleteToken))
|
r.With(server.MustAuth).Delete("/tokens/{id}", server.WrapHandler(s.deleteToken))
|
||||||
|
|
||||||
r.With(server.MustAuth).Get("/export/start", server.WrapHandler(s.startExport))
|
|
||||||
r.With(server.MustAuth).Get("/export", server.WrapHandler(s.getExport))
|
|
||||||
|
|
||||||
// cancel user delete
|
// cancel user delete
|
||||||
// uses a special token, so handled in the function itself
|
// uses a special token, so handled in the function itself
|
||||||
r.Get("/cancel-delete", server.WrapHandler(s.cancelDelete))
|
r.Get("/cancel-delete", server.WrapHandler(s.cancelDelete))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package auth
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
|
@ -1,16 +1,23 @@
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"codeberg.org/u1f320/pronouns.cc/backend/server"
|
"codeberg.org/u1f320/pronouns.cc/backend/server"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
*server.Server
|
*server.Server
|
||||||
|
|
||||||
|
ExporterPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func Mount(srv *server.Server, r chi.Router) {
|
func Mount(srv *server.Server, r chi.Router) {
|
||||||
s := &Server{srv}
|
s := &Server{
|
||||||
|
Server: srv,
|
||||||
|
ExporterPath: "http://127.0.0.1:" + os.Getenv("EXPORTER_PORT"),
|
||||||
|
}
|
||||||
|
|
||||||
r.Route("/users", func(r chi.Router) {
|
r.Route("/users", func(r chi.Router) {
|
||||||
r.Get("/{userRef}", server.WrapHandler(s.getUser))
|
r.Get("/{userRef}", server.WrapHandler(s.getUser))
|
||||||
|
@ -19,6 +26,9 @@ func Mount(srv *server.Server, r chi.Router) {
|
||||||
r.Get("/@me", server.WrapHandler(s.getMeUser))
|
r.Get("/@me", server.WrapHandler(s.getMeUser))
|
||||||
r.Patch("/@me", server.WrapHandler(s.patchUser))
|
r.Patch("/@me", server.WrapHandler(s.patchUser))
|
||||||
r.Delete("/@me", server.WrapHandler(s.deleteUser))
|
r.Delete("/@me", server.WrapHandler(s.deleteUser))
|
||||||
|
|
||||||
|
r.Get("/export/start", server.WrapHandler(s.startExport))
|
||||||
|
r.Get("/export", server.WrapHandler(s.getExport))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
const requestExport = async () => {
|
const requestExport = async () => {
|
||||||
try {
|
try {
|
||||||
await apiFetchClient<any>("/auth/export/start");
|
await apiFetchClient<any>("/users/@me/export/start");
|
||||||
|
|
||||||
addToast({
|
addToast({
|
||||||
header: "Export in progress",
|
header: "Export in progress",
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { error } from "@sveltejs/kit";
|
||||||
|
|
||||||
export const load = async () => {
|
export const load = async () => {
|
||||||
try {
|
try {
|
||||||
const data = await apiFetchClient<ExportResponse>("/auth/export");
|
const data = await apiFetchClient<ExportResponse>("/users/@me/export");
|
||||||
return { exportData: data };
|
return { exportData: data };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if ((e as APIError).code === ErrorCode.NotFound) return { exportData: null };
|
if ((e as APIError).code === ErrorCode.NotFound) return { exportData: null };
|
||||||
|
|
Loading…
Reference in a new issue