Files
api_tmpl/internal/handlers/grpc/converter.go
T
FernandoJVideira c4ee0ce4dc chore: rename simple_bank to api_tmpl and clean up for template use
Rename the module, proto service, and all identifiers from simple_bank/
SimpleBank to api_tmpl/ApiTmpl, and regenerate the gRPC/gateway/swagger/
mock code accordingly.

- Scrub real secrets (SMTP password, auth token secret) from api.env/
  api_test.env, untrack them, and add api.env.example/api_test.env.example
- Remove committed build artifacts (tmp/main, tmp/build-errors.log,
  dbml-error.log) and gitignore them going forward
- Fix Dockerfile paths (build target, migrations copy) that referenced a
  stale project layout
- Rewrite README to match the actual cmd/ + internal/ structure and add a
  "using this as a template" section
2026-08-25 03:02:37 +01:00

39 lines
1020 B
Go

package gapi
import (
"time"
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
"github.com/FernandoJVideira/api_tmpl/pb"
"github.com/google/uuid"
"google.golang.org/protobuf/types/known/timestamppb"
)
func convertUser(user db.User) *pb.User {
return &pb.User{
Username: user.Username,
FullName: user.FullName,
Email: user.Email,
CreatedAt: timestamppb.New(user.CreatedAt),
PasswordChangedAt: timestamppb.New(user.PasswordChangedAt),
}
}
func convertLoginUserResponse(
user db.User,
sessionID uuid.UUID,
accessToken string,
refreshToken string,
accessExpiredAt time.Time,
refreshExpiredAt time.Time,
) *pb.LoginUserResponse {
return &pb.LoginUserResponse{
User: convertUser(user),
SessionId: sessionID.String(),
AccessToken: accessToken,
RefreshToken: refreshToken,
AccessTokenExpiresAt: timestamppb.New(accessExpiredAt),
RefreshTokenExpiresAt: timestamppb.New(refreshExpiredAt),
}
}