Skip to content

Dev#2

Open
BruceGoodGuy wants to merge 7 commits into
mainfrom
dev
Open

Dev#2
BruceGoodGuy wants to merge 7 commits into
mainfrom
dev

Conversation

@BruceGoodGuy
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings May 16, 2026 16:06
@BruceGoodGuy BruceGoodGuy self-assigned this May 16, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR wires up a basic user registration + email confirmation + authentication flow in the Go app, adds an HTML verification email template, introduces Redis Bloom-filter–based email existence checks, and updates Redis/rate-limit infrastructure to support that flow.

Changes:

  • Added verification email templating and updated the mail sender to render HTML templates.
  • Implemented user registration staging in Redis + confirmation endpoint + JWT auth flow (with refresh tokens stored in Redis).
  • Switched Redis client to github.com/redis/go-redis/v9, introduced Bloom filter seeding on startup, and updated Docker Compose to Redis Stack.

Reviewed changes

Copilot reviewed 16 out of 20 changed files in this pull request and generated 23 comments.

Show a summary per file
File Description
README.md Adds a placeholder README line.
go-app/tmp/build-errors.log Removes a tracked build error log.
go-app/templates/verify.html Adds the HTML verification email template.
go-app/pkg/mail/gomail.go Updates mail sender to render and send HTML templates.
go-app/pkg/cache/redis.go Migrates Redis client import to go-redis v9.
go-app/internal/user/service.go Adds auth/token logic and user service methods.
go-app/internal/user/repository.go Adds staged registration in Redis, Bloom filter seeding/checks, confirmation, refresh-token storage.
go-app/internal/user/model.go Adds a secondary user struct type.
go-app/internal/user/handler.go Adds verify/confirm/auth endpoints and additional request handling.
go-app/internal/user/dto.go Adds DTOs for verify/confirm/auth flows.
go-app/internal/test/repository.go Migrates Redis client import to go-redis v9.
go-app/internal/middleware/rate_limit.go Makes rate limiting configurable and constructs limiter store/client.
go-app/internal/app/application.go Injects mail into user repo, adds Bootstrap seeding, updates routes + rate limits.
go-app/go.mod Updates dependencies (JWT, validator, go-redis v9, limiter).
go-app/go.sum Updates dependency checksums.
go-app/cmd/api/main.go Calls application bootstrap before routes.
docker-compose.yml Switches Redis image to redis-stack-server.
.gitignore Ignores go-app/tmp/.
.github/instructions/review.instructions.md Adds repository code review standards/instructions.
Comments suppressed due to low confidence (2)

go-app/internal/middleware/rate_limit.go:23

  • RateLimit creates a brand-new Redis client (and does a Ping) every time the middleware is constructed, which happens multiple times in Routes(). This wastes connections and increases startup latency; inject a shared Redis client/store into the middleware instead of calling cache.Connect() here.
func RateLimit(numberRequest int, period string) gin.HandlerFunc {
	rate, err := limiter.NewRateFromFormatted(fmt.Sprintf("%d-%s", numberRequest, period))
	if err != nil {
		panic(err)
	}

	client := cache.Connect()
	store, err := redis.NewStore(client)

go-app/internal/middleware/rate_limit.go:26

  • This middleware panics on rate parsing/store creation errors. Panics crash the server and are hard to operate; prefer returning an error during app startup (and failing fast with a clear error) rather than panicking from inside middleware construction.
func RateLimit(numberRequest int, period string) gin.HandlerFunc {
	rate, err := limiter.NewRateFromFormatted(fmt.Sprintf("%d-%s", numberRequest, period))
	if err != nil {
		panic(err)
	}

	client := cache.Connect()
	store, err := redis.NewStore(client)
	if err != nil {
		panic(err)
	}

Comment thread README.md
@@ -0,0 +1 @@
comming soon.... really soonnnnnnn

<p style="color: #636e72; font-size: 17px; line-height: 1.8; margin: 0 0 30px 0;">
Your journey to finding the best flavors starts here. We're thrilled to have another
**Food Lover** join our community! To start exploring nearby eats and hidden gems,
Comment thread go-app/pkg/mail/gomail.go
Comment on lines 7 to +11
"log"
"os"
"path/filepath"
"strconv"
"text/template"
Comment thread go-app/pkg/mail/gomail.go
Comment on lines +50 to +56
// 1. Build the path to the template file
// The templates are located in the "templates" folder at the project root
templatePath := filepath.Join("templates", templateName+".html")

// 2. Parse and execute the HTML template
tmpl, err := template.ParseFiles(templatePath)
if err != nil {
Comment thread go-app/internal/user/service.go Outdated
Comment on lines +57 to +59

fmt.Print(token.AccessToken)

Comment thread go-app/internal/user/service.go Outdated
Comment on lines +86 to +87
accessTokenString, err := accessToken.SignedString([]byte(os.Getenv("SECRET_STRING")))
if err != nil {
Comment on lines +172 to +177
defer func() {
if r := recover(); r != nil {
fmt.Printf("[ActivateAccount] DB error, Can't activate account: %v", r)
}
}()

Comment on lines +118 to +119
r.cache.Set(ctx, "register:email:"+u.Email, key, ttl)
r.cache.Set(ctx, "register:token:"+key, string(jsonData), ttl)
Comment on lines +68 to +72
ctx.JSON(http.StatusInternalServerError, response.Response{
IsSuccess: false,
Message: "Failed to create user",
Data: err.Error(),
})
Comment on lines +57 to +60
if isExist, err := h.s.VerifyEmailExist(ctx, user.Email, false); err == nil {
if isExist {
ctx.JSON(http.StatusUnprocessableEntity, response.Response{IsSuccess: false, Message: "Duplicate email"})
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants