This commit is contained in:
Ccjcarkbla
2026-06-30 11:49:26 -04:00
parent e192aecb2f
commit 7a35165bfd
16 changed files with 559 additions and 153 deletions
+4 -3
View File
@@ -7,12 +7,13 @@ const nonNegInt = z.number().int().min(0);
const createTimer = z.object({
name: z.string().min(1).max(200),
totalTime: positiveInt,
timerMode: z.enum(['group', 'crossfit']).optional(),
workoutDate: z.string().optional().nullable(),
exerciseCount: positiveInt,
setCount: positiveInt,
setTime: positiveInt,
restTime: nonNegInt.default(0),
moveTime: nonNegInt.default(0),
setCount: positiveInt,
exerciseCount: positiveInt,
lapCount: positiveInt.default(1),
});
+13
View File
@@ -32,6 +32,19 @@ function init(httpServer) {
io.on('connection', (socket) => {
logger.debug({ userId: socket.data.user?.id }, 'Socket connected');
socket.on('timer:join', ({ sessionId } = {}) => {
if (!sessionId) return;
socket.join(sessionId);
// Lazy require avoids load-time circular dependency
const timerSvc = require('../modules/timers/service');
const engine = timerSvc.getSessionEngine(sessionId);
if (engine) socket.emit('timer:state', engine.getState());
});
socket.on('timer:leave', ({ sessionId } = {}) => {
if (sessionId) socket.leave(sessionId);
});
socket.on('disconnect', (reason) => {
logger.debug({ userId: socket.data.user?.id, reason }, 'Socket disconnected');
});