From fd1332a3df191577e91c6d846a8b5db1747099fd Mon Sep 17 00:00:00 2001 From: Zach Berwaldt Date: Fri, 15 Mar 2024 22:00:10 -0400 Subject: cleanup --- api/internal/router/router.go | 8 ++++---- fe/src/lib/DataView.svelte | 7 ++++--- fe/src/lib/LoginForm.svelte | 3 ++- fe/src/lib/PreferencesForm.svelte | 15 ++++++++------- fe/src/lib/forms/AddForm.svelte | 3 ++- fe/src/utils.ts | 5 +++++ 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/api/internal/router/router.go b/api/internal/router/router.go index 3c86b8c..a71c3e6 100644 --- a/api/internal/router/router.go +++ b/api/internal/router/router.go @@ -30,10 +30,10 @@ func SetupRouter() *gin.Engine { stats := api.Group("/stats") stats.Use(middleware.TokenRequired()) { - stats.GET("/", controllers.GetAllStatistics) - stats.POST("/", controllers.PostNewStatistic) - stats.GET("weekly/", controllers.GetWeeklyStatistics) - stats.GET("daily/", controllers.GetDailyUserStatistics) + stats.GET("", controllers.GetAllStatistics) + stats.POST("", controllers.PostNewStatistic) + stats.GET("weekly", controllers.GetWeeklyStatistics) + stats.GET("daily", controllers.GetDailyUserStatistics) stats.GET("user/:uuid", controllers.GetUserStatistics) stats.PATCH("user/:uuid", controllers.UpdateUserStatistic) stats.DELETE("user/:uuid", controllers.DeleteUserStatistic) diff --git a/fe/src/lib/DataView.svelte b/fe/src/lib/DataView.svelte index 5e81a5a..ffc2fe8 100644 --- a/fe/src/lib/DataView.svelte +++ b/fe/src/lib/DataView.svelte @@ -9,6 +9,7 @@ import Card from "./Card.svelte"; import Column from "./Column.svelte"; import AddForm from "./forms/AddForm.svelte"; + import { apiURL } from "../utils"; let json: Promise; @@ -24,7 +25,7 @@ let userTotalsData: number[]; async function fetchData() { - const res = await fetch("http://localhost:8080/api/v1/stats/", { + const res = await fetch(apiURL("stats"), { method: "GET", headers: { Authorization: `Bearer ${$token}` @@ -38,7 +39,7 @@ } async function fetchDailyUserStatistics() { - const res = await fetch("http://localhost:8080/api/v1/stats/daily/", { + const res = await fetch(apiURL("stats/daily"), { method: "GET", headers: { Authorization: `Bearer ${$token}` @@ -57,7 +58,7 @@ } async function fetchWeeklyTotals() { - const res = await fetch("http://localhost:8080/api/v1/stats/weekly/", { + const res = await fetch(apiURL("stats/weekly"), { method: "GET", headers: { Authorization: `Bearer ${$token}` diff --git a/fe/src/lib/LoginForm.svelte b/fe/src/lib/LoginForm.svelte index 8c3c288..cf5febf 100644 --- a/fe/src/lib/LoginForm.svelte +++ b/fe/src/lib/LoginForm.svelte @@ -1,6 +1,7 @@