From cabd6c3a91d0f929bcbb3fd344e43348d02e42c8 Mon Sep 17 00:00:00 2001 From: toannd96 Date: Sun, 7 Jan 2024 02:39:57 +0700 Subject: [PATCH] update --- fly.toml | 22 ++++++++++++++++++++++ internal/app/auth/repository.go | 3 +++ internal/app/user/delivery_http.go | 5 ++++- web/static/js/record.js | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 fly.toml diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..d649fd1 --- /dev/null +++ b/fly.toml @@ -0,0 +1,22 @@ +# fly.toml app configuration file generated for theodoiweb on 2024-01-07T01:01:37+07:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "theodoiweb" +primary_region = "sin" + +[build] + +[http_service] + internal_port = 8080 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ["app"] + +[[vm]] + cpu_kind = "shared" + cpus = 1 + memory_mb = 256 diff --git a/internal/app/auth/repository.go b/internal/app/auth/repository.go index e48e93a..3b24914 100644 --- a/internal/app/auth/repository.go +++ b/internal/app/auth/repository.go @@ -5,6 +5,8 @@ import ( "analytics-api/internal/pkg/security" "time" + + "github.com/sirupsen/logrus" ) // Repository ... @@ -29,6 +31,7 @@ func (instance *repository) InsertAuth(userID string, tokenDetails *security.Tok errAccess := configs.Redis.Client.Set(tokenDetails.AccessUUID, userID, at.Sub(now)).Err() if errAccess != nil { + logrus.Error("Redis set at error ", errAccess) return errAccess } // errRefresh := configs.Redis.Client.Set(tokenDetails.RefreshUUID, userID, rt.Sub(now)).Err() diff --git a/internal/app/user/delivery_http.go b/internal/app/user/delivery_http.go index 860bddb..85d10c1 100644 --- a/internal/app/user/delivery_http.go +++ b/internal/app/user/delivery_http.go @@ -11,6 +11,7 @@ import ( "analytics-api/internal/pkg/middleware" "github.com/gin-gonic/gin" + "github.com/sirupsen/logrus" ) type httpDelivery struct { @@ -157,12 +158,14 @@ func (instance *httpDelivery) Signin(c *gin.Context) { // create token token, err := security.CreateToken(user.ID) if err != nil { + logrus.Error("Create token error ", err) c.HTML(http.StatusInternalServerError, "500.html", gin.H{}) return } InsertAuthErr := instance.authUsecase.InsertAuth(user.ID, token) if InsertAuthErr != nil { + logrus.Error("Insert auth error ", err) c.HTML(http.StatusInternalServerError, "500.html", gin.H{}) return } @@ -171,7 +174,7 @@ func (instance *httpDelivery) Signin(c *gin.Context) { // user.RefreshToken = token.RefreshToken // create cookie for client - c.SetCookie("access_token", token.AccessToken, 86400, "/", "localhost", false, true) + c.SetCookie("access_token", token.AccessToken, 86400, "/", "theodoiweb.fly.dev", false, true) // c.SetCookie("refresh_token", token.RefreshToken, 86400, "/", "localhost", false, true) // c.JSON(http.StatusOK, user) diff --git a/web/static/js/record.js b/web/static/js/record.js index 5e01378..39d354d 100644 --- a/web/static/js/record.js +++ b/web/static/js/record.js @@ -48,7 +48,7 @@ window.recorder = { start() { window.recorder.runner = setInterval(function receive() { const session = window.recorder.session.get(); - fetch('http://localhost:3000/session/receive', { + fetch('https://theodoiweb.fly.dev/session/receive', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(Object.assign({}, { events: window.recorder.events }, session)),