Frontend UX improvements: - Single-click Discord OAuth from home page (no intermediate /auth page) - Auto-redirect authenticated users from home to /games - Fixed Nuxt layout system - app.vue now wraps NuxtPage with NuxtLayout - Games page now has proper card container with shadow/border styling - Layout header includes working logout with API cookie clearing Games list enhancements: - Display team names (lname) instead of just team IDs - Show current score for each team - Show inning indicator (Top/Bot X) for active games - Responsive header with wrapped buttons on mobile Backend improvements: - Added team caching to SbaApiClient (1-hour TTL) - Enhanced GameListItem with team names, scores, inning data - Games endpoint now enriches response with SBA API team data Docker optimizations: - Optimized Dockerfile using --chown flag on COPY (faster than chown -R) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
982 B
Plaintext
49 lines
982 B
Plaintext
import type { Socket } from 'socket.io-client';
|
|
import { io } from 'socket.io-client'
|
|
|
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
const config = useRuntimeConfig()
|
|
let socket: Socket | null = null
|
|
|
|
const connect = (token: string) => {
|
|
if (socket?.connected) return socket
|
|
|
|
socket = io(config.public.wsUrl, {
|
|
auth: { token },
|
|
reconnection: true,
|
|
reconnectionDelay: 1000,
|
|
reconnectionAttempts: 5
|
|
})
|
|
|
|
socket.on('connect', () => {
|
|
console.log('WebSocket connected')
|
|
})
|
|
|
|
socket.on('disconnect', () => {
|
|
console.log('WebSocket disconnected')
|
|
})
|
|
|
|
socket.on('connect_error', (error) => {
|
|
console.error('WebSocket connection error:', error)
|
|
})
|
|
|
|
return socket
|
|
}
|
|
|
|
const disconnect = () => {
|
|
socket?.disconnect()
|
|
socket = null
|
|
}
|
|
|
|
return {
|
|
provide: {
|
|
socket: {
|
|
connect,
|
|
disconnect,
|
|
get instance() {
|
|
return socket
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}) |