feat: Implement Session Token System with /api/v1 base path

- Add migration 000004 for sessions table and performance indexes
- Create session.sql queries for CRUD operations
- Generate session repository code with sqlc
- Create token auth middleware for Echo framework
- Create token handler with create/delete/cleanup endpoints
- Add /api/v1 router with token authentication infrastructure
- Update dbHelper.go to use Up() instead of Migrate(2)
- Update server.go to initialize token handler
- Existing endpoints remain functional (to be deprecated)

New endpoints:
- POST /api/v1/token - Create new session token
- DELETE /api/v1/token - Invalidate token
- POST /api/v1/token/cleanup - Remove expired sessions

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-06-01 18:07:28 +02:00
parent 8f8b555ea5
commit 6cc014ffa3
11 changed files with 523 additions and 15 deletions
+11
View File
@@ -6,6 +6,8 @@ package repository
import (
"time"
"github.com/jackc/pgx/v5/pgtype"
)
type Game struct {
@@ -21,6 +23,15 @@ type Game struct {
Hash string `json:"hash"`
}
type Session struct {
Token string `json:"token"`
IpAddress string `json:"ip_address"`
UserAgent string `json:"user_agent"`
ClientType *string `json:"client_type"`
ExpiresAt pgtype.Timestamptz `json:"expires_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type Song struct {
GameID int32 `json:"game_id"`
SongName string `json:"song_name"`