Skip to content

Commit fb89a5f

Browse files
committed
lowercase ib
1 parent 645eee1 commit fb89a5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+471
-471
lines changed

api/api.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package api
33
import (
44
"net/http"
55

6-
libCommon "github.com/String-xyz/go-lib/common"
6+
libcommon "github.com/String-xyz/go-lib/common"
77
"github.com/String-xyz/go-lib/database"
88
"github.com/String-xyz/go-lib/middleware"
99
"github.com/String-xyz/go-lib/validator"
1010
"github.com/String-xyz/string-api/api/handler"
11-
libMiddleware "github.com/String-xyz/string-api/api/middleware"
11+
libmiddleware "github.com/String-xyz/string-api/api/middleware"
1212

1313
"github.com/String-xyz/string-api/pkg/service"
1414
"github.com/jmoiron/sqlx"
@@ -34,7 +34,7 @@ func Start(config APIConfig) {
3434

3535
// not internal middlewares
3636
geofencingService := service.NewGeofencing(config.Redis)
37-
e.Use(libMiddleware.Georestrict(geofencingService))
37+
e.Use(libmiddleware.Georestrict(geofencingService))
3838

3939
e.GET("/heartbeat", heartbeat)
4040

@@ -43,7 +43,7 @@ func Start(config APIConfig) {
4343
services := NewServices(config, repos)
4444

4545
// initialize routes - A route group only needs access to the services layer. It should'n access the repos layer directly
46-
AuthAPIKey(services, e, libCommon.IsLocalEnv())
46+
AuthAPIKey(services, e, libcommon.IsLocalEnv())
4747
transactRoute(services, e)
4848
quoteRoute(services, e)
4949
userRoute(services, e)
@@ -80,7 +80,7 @@ func baseMiddleware(logger *zerolog.Logger, e *echo.Echo) {
8080

8181
func platformRoute(services service.Services, e *echo.Echo) {
8282
handler := handler.NewPlatform(services.Platform)
83-
handler.RegisterRoutes(e.Group("/platforms"), libMiddleware.BearerAuth())
83+
handler.RegisterRoutes(e.Group("/platforms"), libmiddleware.BearerAuth())
8484
}
8585

8686
func AuthAPIKey(services service.Services, e *echo.Echo, internal bool) {
@@ -90,17 +90,17 @@ func AuthAPIKey(services service.Services, e *echo.Echo, internal bool) {
9090

9191
func transactRoute(services service.Services, e *echo.Echo) {
9292
handler := handler.NewTransaction(e, services.Transaction)
93-
handler.RegisterRoutes(e.Group("/transactions"), libMiddleware.APIKeyAuth(services.Auth), libMiddleware.BearerAuth())
93+
handler.RegisterRoutes(e.Group("/transactions"), libmiddleware.APIKeyAuth(services.Auth), libmiddleware.BearerAuth())
9494
}
9595

9696
func userRoute(services service.Services, e *echo.Echo) {
9797
handler := handler.NewUser(e, services.User, services.Verification)
98-
handler.RegisterRoutes(e.Group("/users"), libMiddleware.APIKeyAuth(services.Auth), libMiddleware.BearerAuth())
98+
handler.RegisterRoutes(e.Group("/users"), libmiddleware.APIKeyAuth(services.Auth), libmiddleware.BearerAuth())
9999
}
100100

101101
func loginRoute(services service.Services, e *echo.Echo) {
102102
handler := handler.NewLogin(e, services.Auth, services.Device)
103-
handler.RegisterRoutes(e.Group("/login"), libMiddleware.APIKeyAuth(services.Auth))
103+
handler.RegisterRoutes(e.Group("/login"), libmiddleware.APIKeyAuth(services.Auth))
104104
}
105105

106106
func verificationRoute(services service.Services, e *echo.Echo) {
@@ -110,5 +110,5 @@ func verificationRoute(services service.Services, e *echo.Echo) {
110110

111111
func quoteRoute(services service.Services, e *echo.Echo) {
112112
handler := handler.NewQuote(e, services.Transaction)
113-
handler.RegisterRoutes(e.Group("/quotes"), libMiddleware.APIKeyAuth(services.Auth), libMiddleware.BearerAuth())
113+
handler.RegisterRoutes(e.Group("/quotes"), libmiddleware.APIKeyAuth(services.Auth), libmiddleware.BearerAuth())
114114
}

api/handler/auth_key.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package handler
33
import (
44
"net/http"
55

6-
libCommon "github.com/String-xyz/go-lib/common"
6+
libcommon "github.com/String-xyz/go-lib/common"
77
"github.com/String-xyz/go-lib/httperror"
88
"github.com/String-xyz/string-api/pkg/service"
99
"github.com/labstack/echo/v4"
@@ -30,7 +30,7 @@ func NewAuthAPIKey(service service.APIKeyStrategy, internal bool) AuthAPIKey {
3030
func (o authAPIKey) Create(c echo.Context) error {
3131
key, err := o.service.Create()
3232
if err != nil {
33-
libCommon.LogStringError(c, err, "authKey approve: create")
33+
libcommon.LogStringError(c, err, "authKey approve: create")
3434
return echo.NewHTTPError(http.StatusInternalServerError, "Unable to process request")
3535
}
3636
return c.JSON(http.StatusOK, key)
@@ -47,12 +47,12 @@ func (o authAPIKey) List(c echo.Context) error {
4747
}{}
4848
err := c.Bind(&body)
4949
if err != nil {
50-
libCommon.LogStringError(c, err, "authKey list: bind")
50+
libcommon.LogStringError(c, err, "authKey list: bind")
5151
return echo.NewHTTPError(http.StatusBadRequest)
5252
}
5353
list, err := o.service.List(body.Limit, body.Offset, body.Status)
5454
if err != nil {
55-
libCommon.LogStringError(c, err, "authKey list")
55+
libcommon.LogStringError(c, err, "authKey list")
5656
return echo.NewHTTPError(http.StatusInternalServerError, "ApiKey Service Failed")
5757
}
5858
return c.JSON(http.StatusCreated, list)
@@ -68,12 +68,12 @@ func (o authAPIKey) Approve(c echo.Context) error {
6868
err := c.Bind(&params)
6969

7070
if err != nil {
71-
libCommon.LogStringError(c, err, "authKey approve: bind")
71+
libcommon.LogStringError(c, err, "authKey approve: bind")
7272
return echo.NewHTTPError(http.StatusInternalServerError, "Unable to process request")
7373
}
7474
err = o.service.Approve(params.Id)
7575
if err != nil {
76-
libCommon.LogStringError(c, err, "authKey approve: approve")
76+
libcommon.LogStringError(c, err, "authKey approve: approve")
7777
return echo.NewHTTPError(http.StatusInternalServerError, "Unable to process request")
7878
}
7979
return c.JSON(http.StatusOK, ResultMessage{Status: "Success"})

api/handler/common.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77
"time"
88

9-
libCommon "github.com/String-xyz/go-lib/common"
9+
libcommon "github.com/String-xyz/go-lib/common"
1010
service "github.com/String-xyz/string-api/pkg/service"
1111
"golang.org/x/crypto/sha3"
1212

@@ -21,7 +21,7 @@ func SetJWTCookie(c echo.Context, jwt service.JWT) error {
2121
cookie.Expires = jwt.ExpAt // we want the cookie to expire at the same time as the token
2222
cookie.SameSite = getCookieSameSiteMode()
2323
cookie.Path = "/" // Send cookie in every sub path request
24-
cookie.Secure = !libCommon.IsLocalEnv() // in production allow https only
24+
cookie.Secure = !libcommon.IsLocalEnv() // in production allow https only
2525
c.SetCookie(cookie)
2626

2727
return nil
@@ -35,7 +35,7 @@ func SetRefreshTokenCookie(c echo.Context, refresh service.RefreshTokenResponse)
3535
cookie.Expires = refresh.ExpAt // we want the cookie to expire at the same time as the token
3636
cookie.SameSite = getCookieSameSiteMode()
3737
cookie.Path = "/login/" // Send cookie only in /login path request
38-
cookie.Secure = !libCommon.IsLocalEnv() // in production allow https only
38+
cookie.Secure = !libcommon.IsLocalEnv() // in production allow https only
3939
c.SetCookie(cookie)
4040

4141
return nil
@@ -63,7 +63,7 @@ func DeleteAuthCookies(c echo.Context) error {
6363
cookie.Expires = time.Now()
6464
cookie.SameSite = getCookieSameSiteMode()
6565
cookie.Path = "/" // Send cookie in every sub path request
66-
cookie.Secure = !libCommon.IsLocalEnv()
66+
cookie.Secure = !libcommon.IsLocalEnv()
6767
c.SetCookie(cookie)
6868

6969
cookie = new(http.Cookie)
@@ -72,7 +72,7 @@ func DeleteAuthCookies(c echo.Context) error {
7272
cookie.Expires = time.Now()
7373
cookie.SameSite = getCookieSameSiteMode()
7474
cookie.Path = "/login/" // Send cookie only in refresh path request
75-
cookie.Secure = !libCommon.IsLocalEnv()
75+
cookie.Secure = !libcommon.IsLocalEnv()
7676
c.SetCookie(cookie)
7777

7878
return nil
@@ -85,7 +85,7 @@ func validAddress(addr string) bool {
8585

8686
func getCookieSameSiteMode() http.SameSite {
8787
sameSiteMode := http.SameSiteNoneMode // allow cors
88-
if libCommon.IsLocalEnv() {
88+
if libcommon.IsLocalEnv() {
8989
sameSiteMode = http.SameSiteLaxMode // because SameSiteNoneMode is not allowed in localhost we use lax mode
9090
}
9191
return sameSiteMode

api/handler/login.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"os"
77
"strings"
88

9-
libCommon "github.com/String-xyz/go-lib/common"
9+
libcommon "github.com/String-xyz/go-lib/common"
1010
"github.com/String-xyz/go-lib/httperror"
1111
"github.com/String-xyz/string-api/pkg/model"
1212
"github.com/String-xyz/string-api/pkg/service"
@@ -43,7 +43,7 @@ func (l login) NoncePayload(c echo.Context) error {
4343
SanitizeChecksums(&walletAddress)
4444
payload, err := l.Service.PayloadToSign(walletAddress)
4545
if err != nil {
46-
libCommon.LogStringError(c, err, "login: request wallet login")
46+
libcommon.LogStringError(c, err, "login: request wallet login")
4747
return httperror.InternalError(c)
4848
}
4949

@@ -56,7 +56,7 @@ func (l login) VerifySignature(c echo.Context) error {
5656
var body model.WalletSignaturePayloadSigned
5757
err := c.Bind(&body)
5858
if err != nil {
59-
libCommon.LogStringError(c, err, "login: binding body")
59+
libcommon.LogStringError(c, err, "login: binding body")
6060
return httperror.BadRequestError(c)
6161
}
6262

@@ -67,7 +67,7 @@ func (l login) VerifySignature(c echo.Context) error {
6767
// base64 decode nonce
6868
decodedNonce, _ := b64.URLEncoding.DecodeString(body.Nonce)
6969
if err != nil {
70-
libCommon.LogStringError(c, err, "login: verify signature decode nonce")
70+
libcommon.LogStringError(c, err, "login: verify signature decode nonce")
7171
return httperror.BadRequestError(c)
7272
}
7373
body.Nonce = string(decodedNonce)
@@ -81,7 +81,7 @@ func (l login) VerifySignature(c echo.Context) error {
8181
return httperror.BadRequestError(c, "Invalid Email")
8282
}
8383

84-
libCommon.LogStringError(c, err, "login: verify signature")
84+
libcommon.LogStringError(c, err, "login: verify signature")
8585
return httperror.BadRequestError(c, "Invalid Payload")
8686
}
8787

@@ -96,7 +96,7 @@ func (l login) VerifySignature(c echo.Context) error {
9696
// set auth cookies
9797
err = SetAuthCookies(c, resp.JWT)
9898
if err != nil {
99-
libCommon.LogStringError(c, err, "login: unable to set auth cookies")
99+
libcommon.LogStringError(c, err, "login: unable to set auth cookies")
100100
return httperror.InternalError(c)
101101
}
102102

@@ -108,7 +108,7 @@ func (l login) RefreshToken(c echo.Context) error {
108108
var body model.RefreshTokenPayload
109109
err := c.Bind(&body)
110110
if err != nil {
111-
libCommon.LogStringError(c, err, "login: binding body")
111+
libcommon.LogStringError(c, err, "login: binding body")
112112
return httperror.BadRequestError(c)
113113
}
114114

@@ -120,7 +120,7 @@ func (l login) RefreshToken(c echo.Context) error {
120120

121121
cookie, err := c.Cookie("refresh_token")
122122
if err != nil {
123-
libCommon.LogStringError(c, err, "RefreshToken: unable to get refresh_token cookie")
123+
libcommon.LogStringError(c, err, "RefreshToken: unable to get refresh_token cookie")
124124
return httperror.Unauthorized(c)
125125
}
126126

@@ -130,14 +130,14 @@ func (l login) RefreshToken(c echo.Context) error {
130130
return httperror.BadRequestError(c, "wallet address not associated with this user")
131131
}
132132

133-
libCommon.LogStringError(c, err, "login: refresh token")
133+
libcommon.LogStringError(c, err, "login: refresh token")
134134
return httperror.BadRequestError(c, "Invalid or expired token")
135135
}
136136

137137
// set auth in cookies
138138
err = SetAuthCookies(c, resp.JWT)
139139
if err != nil {
140-
libCommon.LogStringError(c, err, "RefreshToken: unable to set auth cookies")
140+
libcommon.LogStringError(c, err, "RefreshToken: unable to set auth cookies")
141141
return httperror.InternalError(c)
142142
}
143143

@@ -149,21 +149,21 @@ func (l login) Logout(c echo.Context) error {
149149
// get refresh token from cookie
150150
cookie, err := c.Cookie("refresh_token")
151151
if err != nil {
152-
libCommon.LogStringError(c, err, "Logout: unable to get refresh_token cookie")
152+
libcommon.LogStringError(c, err, "Logout: unable to get refresh_token cookie")
153153
return httperror.Unauthorized(c)
154154
}
155155

156156
// invalidate refresh token. Returns error if token is not found
157157
err = l.Service.InvalidateRefreshToken(cookie.Value)
158158
if err != nil {
159-
libCommon.LogStringError(c, err, "Token not found")
159+
libcommon.LogStringError(c, err, "Token not found")
160160
}
161161
// There is no need to invalidate the access token since it is a short lived token
162162

163163
// delete auth cookies
164164
err = DeleteAuthCookies(c)
165165
if err != nil {
166-
libCommon.LogStringError(c, err, "Logout: unable to delete auth cookies")
166+
libcommon.LogStringError(c, err, "Logout: unable to delete auth cookies")
167167
return httperror.InternalError(c)
168168
}
169169

api/handler/platform.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package handler
33
import (
44
"net/http"
55

6-
libCommon "github.com/String-xyz/go-lib/common"
6+
libcommon "github.com/String-xyz/go-lib/common"
77
"github.com/String-xyz/string-api/pkg/service"
88
"github.com/labstack/echo/v4"
99
)
@@ -25,13 +25,13 @@ func (p platform) Create(c echo.Context) error {
2525
body := service.CreatePlatform{}
2626
err := c.Bind(&body)
2727
if err != nil {
28-
libCommon.LogStringError(c, err, "platform: create bind")
28+
libcommon.LogStringError(c, err, "platform: create bind")
2929
return echo.NewHTTPError(http.StatusBadRequest)
3030
}
3131

3232
m, err := p.service.Create(body)
3333
if err != nil {
34-
libCommon.LogStringError(c, err, "platform: create")
34+
libcommon.LogStringError(c, err, "platform: create")
3535
return echo.NewHTTPError(http.StatusInternalServerError)
3636
}
3737
return c.JSON(http.StatusCreated, m)

api/handler/quotes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package handler
33
import (
44
"net/http"
55

6-
libCommon "github.com/String-xyz/go-lib/common"
6+
libcommon "github.com/String-xyz/go-lib/common"
77
"github.com/String-xyz/go-lib/httperror"
88
"github.com/String-xyz/string-api/pkg/model"
99
"github.com/String-xyz/string-api/pkg/service"
@@ -30,7 +30,7 @@ func (q quote) Quote(c echo.Context) error {
3030
var body model.TransactionRequest
3131
err := c.Bind(&body) // 'tag' binding: struct fields are annotated
3232
if err != nil {
33-
libCommon.LogStringError(c, err, "quote: quote bind")
33+
libcommon.LogStringError(c, err, "quote: quote bind")
3434
return httperror.BadRequestError(c)
3535
}
3636
SanitizeChecksums(&body.CxAddr, &body.UserAddress)
@@ -44,7 +44,7 @@ func (q quote) Quote(c echo.Context) error {
4444
if err != nil && errors.Cause(err).Error() == "w3: response handling failed: execution reverted" {
4545
return httperror.BadRequestError(c, "The requested blockchain operation will revert")
4646
} else if err != nil {
47-
libCommon.LogStringError(c, err, "quote: quote")
47+
libcommon.LogStringError(c, err, "quote: quote")
4848
return httperror.InternalError(c, "Quote Service Failed")
4949
}
5050
return c.JSON(http.StatusOK, res)

api/handler/transact.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/http"
55
"strings"
66

7-
libCommon "github.com/String-xyz/go-lib/common"
7+
libcommon "github.com/String-xyz/go-lib/common"
88
"github.com/String-xyz/go-lib/httperror"
99
"github.com/String-xyz/string-api/pkg/model"
1010
"github.com/String-xyz/string-api/pkg/service"
@@ -30,7 +30,7 @@ func (t transaction) Transact(c echo.Context) error {
3030
var body model.PrecisionSafeExecutionRequest
3131
err := c.Bind(&body)
3232
if err != nil {
33-
libCommon.LogStringError(c, err, "transact: execute bind")
33+
libcommon.LogStringError(c, err, "transact: execute bind")
3434
return httperror.BadRequestError(c)
3535
}
3636

@@ -45,11 +45,11 @@ func (t transaction) Transact(c echo.Context) error {
4545

4646
res, err := t.Service.Execute(ctx, body, userId, deviceId, ip)
4747
if err != nil && (strings.Contains(err.Error(), "risk:") || strings.Contains(err.Error(), "payment:")) {
48-
libCommon.LogStringError(c, err, "transact: execute")
48+
libcommon.LogStringError(c, err, "transact: execute")
4949
return httperror.Unprocessable(c)
5050
}
5151
if err != nil {
52-
libCommon.LogStringError(c, err, "transact: execute")
52+
libcommon.LogStringError(c, err, "transact: execute")
5353
return httperror.InternalError(c)
5454
}
5555

0 commit comments

Comments
 (0)