From f2d06c21e85e5768176f465fe2d0f655c11512d0 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sun, 13 Nov 2022 13:15:38 -0900 Subject: [PATCH] update API endpoints --- backend/app/api/handlers/v1/v1_ctrl_items.go | 4 ++-- backend/app/api/main.go | 5 ++++- backend/app/api/routes.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/app/api/handlers/v1/v1_ctrl_items.go b/backend/app/api/handlers/v1/v1_ctrl_items.go index f4d43d3..f6bc5ff 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_items.go +++ b/backend/app/api/handlers/v1/v1_ctrl_items.go @@ -65,8 +65,8 @@ func (ctrl *V1Controller) HandleItemsCreate() server.HandlerFunc { return validate.NewRequestError(err, http.StatusInternalServerError) } - user := services.UseUserCtx(r.Context()) - item, err := ctrl.repo.Items.Create(r.Context(), user.GroupID, createData) + ctx := services.NewContext(r.Context()) + item, err := ctrl.svc.Items.Create(ctx, createData) if err != nil { log.Err(err).Msg("failed to create item") return validate.NewRequestError(err, http.StatusInternalServerError) diff --git a/backend/app/api/main.go b/backend/app/api/main.go index c62d5df..c505eea 100644 --- a/backend/app/api/main.go +++ b/backend/app/api/main.go @@ -112,7 +112,10 @@ func run(cfg *config.Config) error { app.db = c app.repos = repo.New(c, cfg.Storage.Data) - app.services = services.New(app.repos) + app.services = services.New( + app.repos, + services.WithAutoIncrementAssetID(cfg.Options.AutoIncrementAssetID), + ) // ========================================================================= // Start Server\ diff --git a/backend/app/api/routes.go b/backend/app/api/routes.go index beec706..cab1a14 100644 --- a/backend/app/api/routes.go +++ b/backend/app/api/routes.go @@ -51,7 +51,7 @@ func (a *app) mountRoutes(repos *repo.AllRepos) { a.services, a.repos, v1.WithMaxUploadSize(a.conf.Web.MaxUploadSize), - v1.WithRegistration(a.conf.AllowRegistration), + v1.WithRegistration(a.conf.Options.AllowRegistration), v1.WithDemoStatus(a.conf.Demo), // Disable Password Change in Demo Mode )