Skip to content

feat: Implement Address and APIKey model logic in Go#64

Merged
dcordz merged 1 commit into
golang-stagingfrom
go-backend-conversion-1
Oct 15, 2025
Merged

feat: Implement Address and APIKey model logic in Go#64
dcordz merged 1 commit into
golang-stagingfrom
go-backend-conversion-1

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

This change continues the migration of business logic from the Rails backend to the new Go application. It implements the core logic for the Address and APIKey models.

Address Model:

  • Implemented data normalization for City and RegionCode using a GORM BeforeSave hook.
  • Added a FullAddress helper method for easy formatting.
  • Added unit tests to verify the new functionality.

APIKey Model:

  • Implemented secure token handling with HMAC-SHA512 hashing via a BeforeCreate hook.
  • Added functions for token authentication.
  • Added unit tests to ensure the security-critical logic is correct.

PR created automatically by Jules for task 15242739009293426383

This commit ports business logic for the Address and APIKey models from the Ruby on Rails application to the Go backend.

For the Address model, this includes:
- A GORM `BeforeSave` hook to normalize the City (title-casing) and RegionCode (uppercasing).
- A `FullAddress` helper method to generate a formatted address string.
- Comprehensive unit tests for the new logic.

For the APIKey model, this includes:
- A GORM `BeforeCreate` hook to securely hash raw API tokens into a `TokenDigest` using HMAC-SHA512.
- `AuthenticateByToken` and `AuthenticateByTokenBang` functions for secure token verification.
- Comprehensive unit tests for the authentication and token generation logic.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

@dcordz dcordz marked this pull request as ready for review October 15, 2025 11:55
@dcordz dcordz changed the base branch from main to golang-staging October 15, 2025 11:55
@dcordz dcordz merged commit f38b40c into golang-staging Oct 15, 2025
2 of 3 checks passed
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.

1 participant