Production config management for any backend — centralized config module, env vars, no hardcoded secrets, fail-fast validation
86
77%
Does it follow best practices?
Impact
100%
1.88xAverage score across 5 eval scenarios
Passed
No known issues
Build a Go REST API for user authentication using JWT tokens. The service connects to PostgreSQL for user storage and uses bcrypt for password hashing.
Endpoints:
POST /api/auth/register -- register a new user (email, password, name)POST /api/auth/login -- authenticate and return JWT access + refresh tokensPOST /api/auth/refresh -- exchange a refresh token for a new access tokenGET /api/auth/me -- get current user profile (requires valid access token)POST /api/auth/logout -- invalidate the refresh tokenBusiness rules:
Use github.com/golang-jwt/jwt/v5 for JWT, github.com/lib/pq for PostgreSQL, and golang.org/x/crypto/bcrypt for hashing.
Produce:
cmd/server/main.go -- application entry pointinternal/handler/auth.go -- HTTP handler for auth endpointsinternal/service/auth.go -- authentication business logicinternal/repository/user.go -- database operations for usersinternal/middleware/auth.go -- JWT authentication middlewarego.mod -- module definition with dependencies.gitignore -- standard Go gitignoreYou may create additional files as needed for a well-structured codebase.