From eb51bdbfef8c2aacf0fdfde279a40de7f74c8d86 Mon Sep 17 00:00:00 2001 From: Zach Berwaldt Date: Mon, 18 Mar 2024 21:27:24 -0400 Subject: clean up, add better error handling --- api/bin/water | Bin 0 -> 15831520 bytes api/internal/controllers/auth.go | 21 +++++++++++++-------- api/internal/controllers/preferences.go | 13 +++++++++---- api/internal/controllers/stats.go | 27 ++++++++++++++++++++++----- api/internal/controllers/user.go | 14 +++++++++++--- api/internal/database/database.go | 18 ++++++++++++------ api/main | Bin 0 -> 17796784 bytes api/water-api.nginx.conf | 8 ++++++++ api/water.service | 14 ++++++++++++++ 9 files changed, 89 insertions(+), 26 deletions(-) create mode 100755 api/bin/water create mode 100755 api/main create mode 100644 api/water-api.nginx.conf create mode 100644 api/water.service (limited to 'api') diff --git a/api/bin/water b/api/bin/water new file mode 100755 index 0000000..b311c73 Binary files /dev/null and b/api/bin/water differ diff --git a/api/internal/controllers/auth.go b/api/internal/controllers/auth.go index ab2fbbb..b06c6ef 100644 --- a/api/internal/controllers/auth.go +++ b/api/internal/controllers/auth.go @@ -5,21 +5,21 @@ import ( "database/sql" "encoding/base64" "errors" - "github.com/gin-gonic/gin" "net/http" "water/api/internal/models" + "github.com/gin-gonic/gin" + + "water/api/internal/database" + _ "github.com/mattn/go-sqlite3" "golang.org/x/crypto/bcrypt" - "water/api/internal/database" ) - - // AuthHandler is a function that handles users' authentication. It checks if the request // has valid credentials, authenticates the user and sets the user's session. // If the authentication is successful, it will allow the user to access protected routes. -func AuthHandler (c *gin.Context) { +func AuthHandler(c *gin.Context) { username, password, ok := c.Request.BasicAuth() if !ok { c.Header("WWW-Authenticate", `Basic realm="Please enter your username and password."`) @@ -27,7 +27,11 @@ func AuthHandler (c *gin.Context) { return } - db := database.EstablishDBConnection() + db, err := database.EstablishDBConnection() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } defer func(db *sql.DB) { err := db.Close() if err != nil { @@ -44,6 +48,8 @@ func AuthHandler (c *gin.Context) { if errors.Is(err, sql.ErrNoRows) { c.JSON(http.StatusNotFound, gin.H{"error": err.Error()}) return + } else { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) } } @@ -64,7 +70,6 @@ func AuthHandler (c *gin.Context) { c.JSON(http.StatusOK, gin.H{"token": apiToken, "user": user, "preferences": preference}) } - // generateToken is a helper function used in the AuthHandler. It generates a random token for API authentication. // This function creates an empty byte slice of length 32 and fills it with cryptographic random data using the rand.Read function. // If an error occurs during the generation, it will return an empty string. @@ -76,4 +81,4 @@ func generateToken() string { return "" } return base64.StdEncoding.EncodeToString(token) -} \ No newline at end of file +} diff --git a/api/internal/controllers/preferences.go b/api/internal/controllers/preferences.go index a1bcf4f..da52e74 100644 --- a/api/internal/controllers/preferences.go +++ b/api/internal/controllers/preferences.go @@ -1,22 +1,27 @@ package controllers import ( - "github.com/gin-gonic/gin" - "net/http" "database/sql" + "net/http" "water/api/internal/database" "water/api/internal/models" + + "github.com/gin-gonic/gin" ) func GetSizes(c *gin.Context) { - db := database.EstablishDBConnection() + db, err := database.EstablishDBConnection() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } defer func(db *sql.DB) { err := db.Close() if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) } }(db) - + rows, err := db.Query("SELECT id, size, unit FROM Sizes") if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) diff --git a/api/internal/controllers/stats.go b/api/internal/controllers/stats.go index 2234787..889b923 100644 --- a/api/internal/controllers/stats.go +++ b/api/internal/controllers/stats.go @@ -2,10 +2,11 @@ package controllers import ( "database/sql" - "github.com/gin-gonic/gin" "net/http" "water/api/internal/database" "water/api/internal/models" + + "github.com/gin-gonic/gin" ) // TODO: add comments to all exported members of package. @@ -13,7 +14,11 @@ import ( // GetAllStatistics connects to the database and queries for all statistics in the database. // If none have been found it will return an error, otherwise a 200 code is sent along with the list of statistics. func GetAllStatistics(c *gin.Context) { - db := database.EstablishDBConnection() + db, err := database.EstablishDBConnection() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } defer func(db *sql.DB) { err := db.Close() if err != nil { @@ -59,7 +64,11 @@ func PostNewStatistic(c *gin.Context) { return } - db := database.EstablishDBConnection() + db, err := database.EstablishDBConnection() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } defer func(db *sql.DB) { err := db.Close() if err != nil { @@ -83,7 +92,11 @@ func PostNewStatistic(c *gin.Context) { } func GetWeeklyStatistics(c *gin.Context) { - db := database.EstablishDBConnection() + db, err := database.EstablishDBConnection() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } defer func(db *sql.DB) { err := db.Close() if err != nil { @@ -118,7 +131,11 @@ func GetWeeklyStatistics(c *gin.Context) { } func GetDailyUserStatistics(c *gin.Context) { - db := database.EstablishDBConnection() + db, err := database.EstablishDBConnection() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } defer func(db *sql.DB) { err := db.Close() if err != nil { diff --git a/api/internal/controllers/user.go b/api/internal/controllers/user.go index dbb09cf..fa9617a 100644 --- a/api/internal/controllers/user.go +++ b/api/internal/controllers/user.go @@ -15,7 +15,11 @@ func GetUser(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"message": "User found"}) } func GetUserPreferences(c *gin.Context) { - db := database.EstablishDBConnection() + db, err := database.EstablishDBConnection() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } defer func(db *sql.DB) { err := db.Close() if err != nil { @@ -41,7 +45,11 @@ func GetUserPreferences(c *gin.Context) { } func UpdateUserPreferences(c *gin.Context) { - db := database.EstablishDBConnection() + db, err := database.EstablishDBConnection() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } defer func(db *sql.DB) { err := db.Close() if err != nil { @@ -58,7 +66,7 @@ func UpdateUserPreferences(c *gin.Context) { log.Printf("newPreferences: %v", newPreferences) - _, err := db.Exec("UPDATE Preferences SET color = ?, size_id = ? WHERE id = ?", newPreferences.Color, newPreferences.SizeID, newPreferences.ID) + _, err = db.Exec("UPDATE Preferences SET color = ?, size_id = ? WHERE id = ?", newPreferences.Color, newPreferences.SizeID, newPreferences.ID) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return diff --git a/api/internal/database/database.go b/api/internal/database/database.go index 1866655..1a55127 100644 --- a/api/internal/database/database.go +++ b/api/internal/database/database.go @@ -2,23 +2,29 @@ package database import ( "database/sql" - _ "github.com/mattn/go-sqlite3" + "fmt" "log" "path/filepath" "water/api/internal/config" + + _ "github.com/mattn/go-sqlite3" ) -func EstablishDBConnection() *sql.DB { +func EstablishDBConnection() (*sql.DB, error) { c, err := config.Load() + if err != nil { + return nil, fmt.Errorf("error while reading config file: %w", err) + } driver := c.GetString("DB_DRIVER") path, err := filepath.Abs(c.GetString("DB_PATH")) + log.Println("my db path: ", path) if err != nil { - log.Fatal("There was and error getting the absolute path of the database.") + return nil, fmt.Errorf("failed to get absolute path of the database: %w", err) } db, err := sql.Open(driver, path) if err != nil { - panic(err) + return nil, fmt.Errorf("error while opening the database: %w", err) } - return db -} \ No newline at end of file + return db, nil +} diff --git a/api/main b/api/main new file mode 100755 index 0000000..1eeaf51 Binary files /dev/null and b/api/main differ diff --git a/api/water-api.nginx.conf b/api/water-api.nginx.conf new file mode 100644 index 0000000..73b0d7c --- /dev/null +++ b/api/water-api.nginx.conf @@ -0,0 +1,8 @@ +server { + listen 443 ssl; + listen [::]:443 ssl; + server_name water-api.example.com; + location / { + proxy_pass http://localhost:8888; + } +} diff --git a/api/water.service b/api/water.service new file mode 100644 index 0000000..eb8a779 --- /dev/null +++ b/api/water.service @@ -0,0 +1,14 @@ +[Unit] +Description=Water is a backend for tracking water consumption +StartLimitIntervalSec=600 +StartLimitBurst=2 + +[Service] +WorkingDirectory=/path/to/water/binary +User=water +Restart=on-failure +RestartSec=30 +PermissionsStartOnly=true + +[Install] +WantedBy=multi-user.target -- cgit v1.1 From 655aeaac60c7dec09276f469904752c7dc58c8c5 Mon Sep 17 00:00:00 2001 From: Zach Berwaldt Date: Mon, 18 Mar 2024 21:29:11 -0400 Subject: remove unnessary logs. --- api/internal/controllers/user.go | 3 --- api/internal/database/database.go | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'api') diff --git a/api/internal/controllers/user.go b/api/internal/controllers/user.go index fa9617a..a0efdc8 100644 --- a/api/internal/controllers/user.go +++ b/api/internal/controllers/user.go @@ -3,7 +3,6 @@ package controllers import ( "database/sql" "errors" - "log" "net/http" "water/api/internal/database" "water/api/internal/models" @@ -64,8 +63,6 @@ func UpdateUserPreferences(c *gin.Context) { return } - log.Printf("newPreferences: %v", newPreferences) - _, err = db.Exec("UPDATE Preferences SET color = ?, size_id = ? WHERE id = ?", newPreferences.Color, newPreferences.SizeID, newPreferences.ID) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) diff --git a/api/internal/database/database.go b/api/internal/database/database.go index 1a55127..1bfb789 100644 --- a/api/internal/database/database.go +++ b/api/internal/database/database.go @@ -3,7 +3,6 @@ package database import ( "database/sql" "fmt" - "log" "path/filepath" "water/api/internal/config" @@ -18,7 +17,7 @@ func EstablishDBConnection() (*sql.DB, error) { driver := c.GetString("DB_DRIVER") path, err := filepath.Abs(c.GetString("DB_PATH")) - log.Println("my db path: ", path) + if err != nil { return nil, fmt.Errorf("failed to get absolute path of the database: %w", err) } -- cgit v1.1 From fd6f6f169f9ff9a1247228fb34dc9654a9584915 Mon Sep 17 00:00:00 2001 From: Zach Berwaldt Date: Thu, 21 Mar 2024 11:23:42 -0400 Subject: fix bugs, redo layout, reorg. --- api/go.mod | 8 +++++++- api/go.sum | 17 +++++++++++++++-- api/internal/controllers/auth.go | 2 +- api/internal/database/database.go | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) (limited to 'api') diff --git a/api/go.mod b/api/go.mod index 6c414bc..06f7b7e 100644 --- a/api/go.mod +++ b/api/go.mod @@ -4,8 +4,8 @@ go 1.18 require ( github.com/gin-gonic/gin v1.9.1 + github.com/glebarez/go-sqlite v1.22.0 github.com/google/uuid v1.6.0 - github.com/mattn/go-sqlite3 v1.14.22 github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.8.4 golang.org/x/crypto v0.19.0 @@ -16,6 +16,7 @@ require ( github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect @@ -34,6 +35,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect @@ -53,4 +55,8 @@ require ( google.golang.org/protobuf v1.32.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + modernc.org/libc v1.37.6 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/memory v1.7.2 // indirect + modernc.org/sqlite v1.28.0 // indirect ) diff --git a/api/go.sum b/api/go.sum index 20771f7..44afdf8 100644 --- a/api/go.sum +++ b/api/go.sum @@ -13,6 +13,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= @@ -22,6 +24,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ= +github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -33,6 +37,7 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -51,8 +56,6 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= -github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -65,6 +68,8 @@ github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdU github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= @@ -124,5 +129,13 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +modernc.org/libc v1.37.6 h1:orZH3c5wmhIQFTXF+Nt+eeauyd+ZIt2BX6ARe+kD+aw= +modernc.org/libc v1.37.6/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= +modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= +modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ= +modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/api/internal/controllers/auth.go b/api/internal/controllers/auth.go index b06c6ef..2599550 100644 --- a/api/internal/controllers/auth.go +++ b/api/internal/controllers/auth.go @@ -12,7 +12,7 @@ import ( "water/api/internal/database" - _ "github.com/mattn/go-sqlite3" + _ "github.com/glebarez/go-sqlite" "golang.org/x/crypto/bcrypt" ) diff --git a/api/internal/database/database.go b/api/internal/database/database.go index 1bfb789..8a54e4a 100644 --- a/api/internal/database/database.go +++ b/api/internal/database/database.go @@ -6,7 +6,7 @@ import ( "path/filepath" "water/api/internal/config" - _ "github.com/mattn/go-sqlite3" + _ "github.com/glebarez/go-sqlite" ) func EstablishDBConnection() (*sql.DB, error) { -- cgit v1.1