feat: initial commit — backend API + student cabinet frontend
- Go backend: auth (JWT), points earn/spend, QR token generation, partners, admin grant/stats endpoints with chi router - Next.js 14 frontend: login, student dashboard, transaction history, QR display, partners list - PostgreSQL migrations (4 tables), Redis cache, Docker Compose - CORS middleware, role-based route protection, Zustand auth store Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// Package cache provides Redis client initialization.
|
||||
package cache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
// NewClient creates and validates a Redis client using the given REDIS_URL.
|
||||
// Returns an error if the URL cannot be parsed or if the initial PING fails.
|
||||
func NewClient(ctx context.Context, redisURL string) (*redis.Client, error) {
|
||||
opts, err := redis.ParseURL(redisURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cache.NewClient: parse URL: %w", err)
|
||||
}
|
||||
client := redis.NewClient(opts)
|
||||
if err := client.Ping(ctx).Err(); err != nil {
|
||||
return nil, fmt.Errorf("cache.NewClient: ping: %w", err)
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
Reference in New Issue
Block a user