Timer implemented. No working tests.

This commit is contained in:
AG
2025-12-10 23:07:31 +02:00
parent 3df4abba47
commit b86664816d
24 changed files with 806 additions and 116 deletions

Binary file not shown.

View File

@@ -1,5 +0,0 @@
module.exports = {
datasource: {
url: process.env.DATABASE_URL,
},
};

5
server/prisma.config.ts Normal file
View File

@@ -0,0 +1,5 @@
export default {
datasource: {
url: process.env.DATABASE_URL || "file:./dev.db",
},
};

Binary file not shown.

View File

@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "PlanExercise" ADD COLUMN "restTime" INTEGER;
-- AlterTable
ALTER TABLE "UserProfile" ADD COLUMN "restTimerDefault" INTEGER DEFAULT 120;

View File

@@ -46,6 +46,7 @@ model UserProfile {
gender String?
birthDate DateTime?
language String? @default("en")
restTimerDefault Int? @default(120) // Default rest timer in seconds
}
model Exercise {
@@ -116,5 +117,6 @@ model PlanExercise {
exercise Exercise @relation(fields: [exerciseId], references: [id])
order Int
isWeighted Boolean @default(false)
restTime Int? // Optional rest time target in seconds
}

Binary file not shown.

BIN
server/prod.db Normal file

Binary file not shown.

View File

@@ -71,9 +71,9 @@ export class AuthController {
const userId = req.user.userId;
await AuthService.updateProfile(userId, req.body);
return sendSuccess(res, null);
} catch (error) {
} catch (error: any) {
logger.error('Error in updateProfile', { error });
return sendError(res, 'Server error', 500);
return sendError(res, error.message || 'Server error', 500);
}
}

View File

@@ -20,9 +20,9 @@ export class PlanController {
const userId = req.user.userId;
const plan = await PlanService.savePlan(userId, req.body);
return sendSuccess(res, plan);
} catch (error) {
} catch (error: any) {
logger.error('Error in savePlan', { error });
return sendError(res, 'Server error', 500);
return sendError(res, error.message || 'Server error', 500);
}
}

View File

@@ -27,6 +27,7 @@ export const updateProfileSchema = z.object({
height: z.number().optional(),
gender: z.string().optional(),
birthDate: z.string().optional(),
language: z.string().optional()
language: z.string().optional(),
restTimerDefault: z.number().optional()
})
})

View File

@@ -1,3 +1,4 @@
// forcing reload
import prisma from '../lib/prisma';
export class PlanService {
@@ -21,6 +22,7 @@ export class PlanService {
exerciseName: pe.exercise.name,
exerciseType: pe.exercise.type,
isWeighted: pe.isWeighted,
restTimeSeconds: pe.restTime
}))
}));
}
@@ -54,7 +56,8 @@ export class PlanService {
planId: id,
exerciseId: step.exerciseId,
order: index,
isWeighted: step.isWeighted || false
isWeighted: step.isWeighted || false,
restTime: step.restTimeSeconds
}))
});
}
@@ -79,7 +82,8 @@ export class PlanService {
exerciseId: pe.exerciseId,
exerciseName: pe.exercise.name,
exerciseType: pe.exercise.type,
isWeighted: pe.isWeighted
isWeighted: pe.isWeighted,
restTimeSeconds: pe.restTime
}))
};
}

Binary file not shown.