created basic project structure
This commit is contained in:
81
CLAUDE.md
Normal file
81
CLAUDE.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
Gym Tracker is a containerized web application for tracking gym sessions and muscle group training frequency. It displays a heatmap of workout sessions, tracks muscle group balance, and provides insights into training patterns.
|
||||
|
||||
**Tech Stack:**
|
||||
- **Backend:** Node.js with Express (REST API)
|
||||
- **Database:** SQLite (file-based, for simplicity)
|
||||
- **Frontend:** Vanilla JavaScript (no build process)
|
||||
- **Deployment:** Docker container with Nginx reverse proxy
|
||||
|
||||
## Commands
|
||||
|
||||
### Backend Development
|
||||
```bash
|
||||
# Install dependencies
|
||||
cd backend && npm install
|
||||
|
||||
# Start the backend server (port 3000)
|
||||
npm start
|
||||
```
|
||||
|
||||
### Docker
|
||||
```bash
|
||||
# Build the Docker image
|
||||
docker build -t gym-tracker .
|
||||
|
||||
# Run the container
|
||||
docker run -p 80:80 -p 3000:3000 -v $(pwd)/data:/app/data gym-tracker
|
||||
|
||||
# Note: Volume mount for /app/data ensures SQLite database persists across restarts
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
### Backend Structure
|
||||
- **`backend/server.js`**: Express server with REST API endpoints
|
||||
- `GET /api/sessions` - Fetch all gym sessions
|
||||
- `POST /api/sessions` - Create new session (requires date and muscle_groups array)
|
||||
- `PUT /api/sessions/:id` - Update existing session
|
||||
- `DELETE /api/sessions/:id` - Delete session
|
||||
- **`backend/database.js`**: SQLite database layer with schema and query functions
|
||||
- **Database schema**: Single `sessions` table with columns: `id` (TEXT), `date` (TEXT, ISO format), `muscle_groups` (TEXT, JSON array)
|
||||
|
||||
### Frontend Structure
|
||||
- **`frontend/index.html`**: Main HTML structure
|
||||
- **`frontend/app.js`**: Core application logic and state management
|
||||
- **`frontend/api.js`**: API client for backend communication
|
||||
- **`frontend/styles.css`**: Application styling
|
||||
- **Frontend architecture**: Modular vanilla JS without build tools, served directly by Nginx
|
||||
|
||||
### Muscle Groups
|
||||
The application tracks 6 muscle groups: Chest, Legs, Delts (shoulders), Lats (back), Triceps, Biceps
|
||||
|
||||
### Balance Indicator Logic
|
||||
- **Happy**: All 6 muscle groups trained 2+ times in last 7 days
|
||||
- **Neutral**: All 6 muscle groups trained 1+ times in last 7 days
|
||||
- **Angry**: Any muscle group not trained in last 7 days
|
||||
|
||||
### Docker Configuration
|
||||
- Single container runs both Nginx (frontend) and Express (backend)
|
||||
- Nginx serves static files and proxies `/api/*` requests to Express
|
||||
- SQLite database requires volume mount for persistence
|
||||
- Ports: 80 (Nginx/HTTP), 3000 (Express API)
|
||||
|
||||
## Important Implementation Details
|
||||
|
||||
### Date Format
|
||||
All dates are stored and transmitted in ISO 8601 format (YYYY-MM-DD) for consistency between frontend and backend.
|
||||
|
||||
### Session IDs
|
||||
Sessions use UUID format for unique identification.
|
||||
|
||||
### Muscle Groups Storage
|
||||
Muscle groups are stored as JSON-encoded arrays in the SQLite TEXT column, e.g., `["Chest", "Legs", "Delts"]`.
|
||||
|
||||
### Heatmap Implementation
|
||||
Uses Cal-Heatmap library (loaded via CDN) to visualize workout frequency across the year.
|
||||
0
Dockerfile
Normal file
0
Dockerfile
Normal file
313
PLAN.md
Normal file
313
PLAN.md
Normal file
@@ -0,0 +1,313 @@
|
||||
# Gym Tracker App - Implementation Plan
|
||||
|
||||
## Overview
|
||||
|
||||
This document outlines the step-by-step implementation plan for building the Gym Tracker application based on the Product Design Document. The application will be containerized using Docker and consist of a Node.js/Express backend with SQLite database, and a vanilla JavaScript frontend served by Nginx.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
gym-tracker/
|
||||
├── backend/
|
||||
│ ├── server.js # Express server and API routes
|
||||
│ ├── database.js # SQLite database setup and queries
|
||||
│ ├── package.json # Node.js dependencies
|
||||
│ └── package-lock.json
|
||||
├── frontend/
|
||||
│ ├── index.html # Main HTML file
|
||||
│ ├── styles.css # CSS styling
|
||||
│ ├── app.js # Main application logic
|
||||
│ ├── heatmap.js # Heatmap component logic
|
||||
│ ├── muscleGroups.js # Muscle group tracking logic
|
||||
│ └── api.js # API client for backend communication
|
||||
├── nginx/
|
||||
│ └── nginx.conf # Nginx configuration
|
||||
├── Dockerfile # Docker container definition
|
||||
└── README.md # Setup and usage instructions
|
||||
```
|
||||
|
||||
## Implementation Phases
|
||||
|
||||
### Phase 1: Backend Setup
|
||||
|
||||
#### Step 1.1: Initialize Node.js Backend
|
||||
- [ ] Create `backend/` directory
|
||||
- [ ] Initialize npm project (`npm init`)
|
||||
- [ ] Install dependencies:
|
||||
- `express` - Web framework
|
||||
- `sqlite3` - SQLite database driver
|
||||
- `cors` - Enable CORS for API
|
||||
- `body-parser` - Parse JSON request bodies
|
||||
- `uuid` - Generate unique session IDs
|
||||
|
||||
#### Step 1.2: Create Database Schema
|
||||
- [ ] Create `database.js` file
|
||||
- [ ] Define SQLite database initialization
|
||||
- [ ] Create `sessions` table with schema:
|
||||
```sql
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
id TEXT PRIMARY KEY,
|
||||
date TEXT NOT NULL,
|
||||
muscle_groups TEXT NOT NULL
|
||||
);
|
||||
```
|
||||
- [ ] Implement database connection management
|
||||
- [ ] Add error handling for database operations
|
||||
|
||||
#### Step 1.3: Build API Endpoints
|
||||
- [ ] Create `server.js` with Express setup
|
||||
- [ ] Implement `GET /api/sessions` - Fetch all sessions
|
||||
- [ ] Implement `POST /api/sessions` - Create new session
|
||||
- Validate date format
|
||||
- Validate muscle_groups array
|
||||
- Generate unique ID
|
||||
- [ ] Implement `PUT /api/sessions/:id` - Update session
|
||||
- Validate session exists
|
||||
- Validate input data
|
||||
- [ ] Implement `DELETE /api/sessions/:id` - Delete session
|
||||
- [ ] Add error handling and appropriate HTTP status codes
|
||||
- [ ] Enable CORS for frontend access
|
||||
|
||||
#### Step 1.4: Test Backend API
|
||||
- [ ] Test each endpoint with curl or Postman
|
||||
- [ ] Verify data persistence in SQLite
|
||||
- [ ] Test edge cases (invalid data, missing sessions, etc.)
|
||||
|
||||
### Phase 2: Frontend Development
|
||||
|
||||
#### Step 2.1: HTML Structure
|
||||
- [ ] Create `frontend/index.html`
|
||||
- [ ] Define semantic HTML structure:
|
||||
- Header with app title and balance indicator
|
||||
- "Add Today's Workout" button
|
||||
- Heatmap container
|
||||
- Muscle groups dashboard (6 cards)
|
||||
- Modal/form for adding sessions
|
||||
- [ ] Include CDN links for Cal-Heatmap
|
||||
- [ ] Link CSS and JS files
|
||||
|
||||
#### Step 2.2: CSS Styling
|
||||
- [ ] Create `frontend/styles.css`
|
||||
- [ ] Style header and navigation
|
||||
- [ ] Style balance indicator (emoji + status text)
|
||||
- [ ] Style "Add Workout" button
|
||||
- [ ] Style heatmap container
|
||||
- [ ] Style muscle group cards:
|
||||
- Color-coded indicators (green/yellow/red)
|
||||
- Display days since last trained
|
||||
- Display training counts
|
||||
- [ ] Style modal/form for session entry
|
||||
- [ ] Add responsive design for mobile devices
|
||||
- [ ] Implement color scheme and typography
|
||||
|
||||
#### Step 2.3: API Client Layer
|
||||
- [ ] Create `frontend/api.js`
|
||||
- [ ] Implement `fetchSessions()` function
|
||||
- [ ] Implement `createSession(session)` function
|
||||
- [ ] Implement `updateSession(id, session)` function
|
||||
- [ ] Implement `deleteSession(id)` function
|
||||
- [ ] Add error handling for network requests
|
||||
- [ ] Add loading states
|
||||
|
||||
#### Step 2.4: Core Application Logic
|
||||
- [ ] Create `frontend/app.js`
|
||||
- [ ] Initialize application state:
|
||||
- Sessions array
|
||||
- Muscle groups configuration
|
||||
- [ ] Implement session management:
|
||||
- Load sessions on page load
|
||||
- Add new session functionality
|
||||
- Edit session functionality
|
||||
- Delete session functionality
|
||||
- [ ] Implement data calculation functions:
|
||||
- Calculate days since last trained per muscle group
|
||||
- Calculate training frequency (7 days, 30 days)
|
||||
- Calculate balance indicator score
|
||||
- [ ] Implement UI update functions:
|
||||
- Update muscle group cards
|
||||
- Update balance indicator
|
||||
- Refresh heatmap
|
||||
|
||||
#### Step 2.5: Heatmap Component
|
||||
- [ ] Create `frontend/heatmap.js`
|
||||
- [ ] Initialize Cal-Heatmap with configuration:
|
||||
- Set date range (current year)
|
||||
- Configure color scheme (green/grey)
|
||||
- Set domain and subDomain
|
||||
- [ ] Transform sessions data for Cal-Heatmap format
|
||||
- [ ] Implement tooltip showing:
|
||||
- Date
|
||||
- Muscle groups trained
|
||||
- [ ] Add navigation controls (previous/next year)
|
||||
- [ ] Handle click events on heatmap cells
|
||||
|
||||
#### Step 2.6: Muscle Groups Dashboard
|
||||
- [ ] Create `frontend/muscleGroups.js`
|
||||
- [ ] Define muscle groups configuration:
|
||||
- Chest, Legs, Delts, Lats, Triceps, Biceps
|
||||
- [ ] Implement rendering of muscle group cards
|
||||
- [ ] Calculate and display for each muscle group:
|
||||
- Days since last trained
|
||||
- Training count (last 7 days / last 30 days)
|
||||
- Color-coded status indicator
|
||||
- [ ] Update cards when sessions change
|
||||
|
||||
#### Step 2.7: Balance Indicator
|
||||
- [ ] Implement balance score calculation logic:
|
||||
- Happy: All 6 groups trained 2+ times in last 7 days
|
||||
- Neutral: All 6 groups trained 1+ times in last 7 days
|
||||
- Angry: Any group not trained in last 7 days
|
||||
- [ ] Render emoji and status text
|
||||
- [ ] Update indicator when sessions change
|
||||
|
||||
#### Step 2.8: Session Form/Modal
|
||||
- [ ] Create modal UI for adding/editing sessions
|
||||
- [ ] Implement form with:
|
||||
- Date picker (default: today)
|
||||
- Checkboxes for 6 muscle groups
|
||||
- Save button
|
||||
- Cancel button
|
||||
- [ ] Handle form submission
|
||||
- [ ] Validate form inputs
|
||||
- [ ] Clear form after submission
|
||||
- [ ] Close modal after save
|
||||
|
||||
### Phase 3: Docker Configuration
|
||||
|
||||
#### Step 3.1: Create Dockerfile
|
||||
- [ ] Create `Dockerfile` in root directory
|
||||
- [ ] Use multi-stage build:
|
||||
- Stage 1: Install Node.js dependencies
|
||||
- Stage 2: Copy backend and frontend files
|
||||
- Stage 3: Install and configure Nginx
|
||||
- [ ] Copy backend files to container
|
||||
- [ ] Copy frontend files to Nginx html directory
|
||||
- [ ] Expose ports (80 for Nginx, 3000 for Express)
|
||||
- [ ] Set up startup command to run both services
|
||||
|
||||
#### Step 3.2: Configure Nginx
|
||||
- [ ] Create `nginx/nginx.conf`
|
||||
- [ ] Configure Nginx to:
|
||||
- Serve static files from `/usr/share/nginx/html`
|
||||
- Proxy `/api/*` requests to Express backend
|
||||
- Set appropriate headers
|
||||
- [ ] Configure port 80 for HTTP
|
||||
|
||||
#### Step 3.3: Test Docker Build
|
||||
- [ ] Build Docker image
|
||||
- [ ] Run container locally
|
||||
- [ ] Verify frontend loads correctly
|
||||
- [ ] Verify API endpoints work through Nginx proxy
|
||||
- [ ] Verify database persistence across container restarts
|
||||
- [ ] Test complete workflow (add/edit/delete sessions)
|
||||
|
||||
### Phase 4: Integration and Testing
|
||||
|
||||
#### Step 4.1: End-to-End Testing
|
||||
- [ ] Test adding multiple sessions
|
||||
- [ ] Test multiple sessions on same day
|
||||
- [ ] Test editing sessions
|
||||
- [ ] Test deleting sessions
|
||||
- [ ] Verify heatmap updates correctly
|
||||
- [ ] Verify muscle group stats update correctly
|
||||
- [ ] Verify balance indicator changes appropriately
|
||||
|
||||
#### Step 4.2: Edge Case Testing
|
||||
- [ ] Test with empty database (first use)
|
||||
- [ ] Test with many sessions (performance)
|
||||
- [ ] Test date boundaries (year transitions)
|
||||
- [ ] Test all muscle groups selected
|
||||
- [ ] Test no muscle groups selected (validation)
|
||||
- [ ] Test invalid date inputs
|
||||
|
||||
#### Step 4.3: UI/UX Polish
|
||||
- [ ] Review and improve styling
|
||||
- [ ] Add loading indicators
|
||||
- [ ] Add success/error messages
|
||||
- [ ] Improve mobile responsiveness
|
||||
- [ ] Test across different browsers
|
||||
- [ ] Optimize performance
|
||||
|
||||
### Phase 5: Documentation and Deployment
|
||||
|
||||
#### Step 5.1: Create README
|
||||
- [ ] Write `README.md` with:
|
||||
- Project overview
|
||||
- Prerequisites (Docker installed)
|
||||
- Installation instructions
|
||||
- Usage instructions
|
||||
- Docker commands reference
|
||||
- Backup recommendations
|
||||
- Troubleshooting guide
|
||||
|
||||
#### Step 5.2: Deployment Preparation
|
||||
- [ ] Document Docker build process
|
||||
- [ ] Document port configuration
|
||||
- [ ] Document volume mount for data persistence
|
||||
- [ ] Create startup scripts if needed
|
||||
- [ ] Document environment variables
|
||||
|
||||
#### Step 5.3: Final Review
|
||||
- [ ] Code review and cleanup
|
||||
- [ ] Remove console.logs and debug code
|
||||
- [ ] Optimize bundle size
|
||||
- [ ] Verify all PRD requirements met
|
||||
- [ ] Test final Docker image
|
||||
|
||||
## Development Order Recommendation
|
||||
|
||||
**Recommended sequence for building:**
|
||||
|
||||
1. **Backend First** (Phase 1)
|
||||
- Build and test API independently
|
||||
- Ensures data layer is solid before frontend
|
||||
|
||||
2. **Frontend Core** (Phase 2.1-2.4)
|
||||
- HTML structure and basic styling
|
||||
- API client and core logic
|
||||
- Can test with mock data initially
|
||||
|
||||
3. **Frontend Components** (Phase 2.5-2.8)
|
||||
- Heatmap integration
|
||||
- Muscle groups dashboard
|
||||
- Balance indicator
|
||||
- Session form
|
||||
|
||||
4. **Docker Integration** (Phase 3)
|
||||
- Containerize application
|
||||
- Configure Nginx proxy
|
||||
|
||||
5. **Testing & Polish** (Phase 4-5)
|
||||
- End-to-end testing
|
||||
- Documentation
|
||||
- Final deployment preparation
|
||||
|
||||
## Key Technical Decisions
|
||||
|
||||
### Database Design
|
||||
- **Single table:** Simple schema with JSON-encoded muscle_groups array
|
||||
- **Text IDs:** Using UUIDs for session identification
|
||||
- **Date format:** ISO 8601 string format (YYYY-MM-DD) for consistency
|
||||
|
||||
### Frontend Architecture
|
||||
- **Modular files:** Separate concerns (app logic, heatmap, muscle groups, API)
|
||||
- **No build process:** Vanilla JS served directly
|
||||
- **Cal-Heatmap:** Mature library for heatmap visualization
|
||||
|
||||
### Docker Strategy
|
||||
- **Single container:** Both Nginx and Express in one container for simplicity
|
||||
- **Volume mount:** Persistent data storage outside container
|
||||
- **Nginx proxy:** Clean separation of static and API requests
|
||||
|
||||
## Success Criteria
|
||||
|
||||
- ✅ Application runs in Docker container
|
||||
- ✅ All API endpoints function correctly
|
||||
- ✅ Heatmap displays gym sessions accurately
|
||||
- ✅ Muscle group tracking calculates correctly
|
||||
- ✅ Balance indicator shows appropriate status
|
||||
- ✅ Sessions can be added, edited, and deleted
|
||||
- ✅ Data persists across container restarts
|
||||
- ✅ UI is responsive and user-friendly
|
||||
- ✅ All PRD requirements implemented
|
||||
|
||||
1
backend/.gitignore
vendored
Normal file
1
backend/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
136
backend/database.js
Normal file
136
backend/database.js
Normal file
@@ -0,0 +1,136 @@
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
const path = require('path');
|
||||
|
||||
// Database file path
|
||||
const DB_PATH = path.join(__dirname, '../data/gym-tracker.db');
|
||||
|
||||
// Initialize database connection
|
||||
const db = new sqlite3.Database(DB_PATH, (err) => {
|
||||
if (err) {
|
||||
console.error('Error opening database:', err.message);
|
||||
} else {
|
||||
console.log('Connected to SQLite database at', DB_PATH);
|
||||
initializeDatabase();
|
||||
}
|
||||
});
|
||||
|
||||
// Create tables if they don't exist
|
||||
function initializeDatabase() {
|
||||
const createTableSQL = `
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
id TEXT PRIMARY KEY,
|
||||
date TEXT NOT NULL,
|
||||
muscle_groups TEXT NOT NULL
|
||||
)
|
||||
`;
|
||||
|
||||
db.run(createTableSQL, (err) => {
|
||||
if (err) {
|
||||
console.error('Error creating sessions table:', err.message);
|
||||
} else {
|
||||
console.log('Sessions table ready');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Get all sessions
|
||||
function getAllSessions(callback) {
|
||||
const sql = 'SELECT * FROM sessions ORDER BY date DESC';
|
||||
db.all(sql, [], (err, rows) => {
|
||||
if (err) {
|
||||
callback(err, null);
|
||||
} else {
|
||||
// Parse muscle_groups JSON string back to array
|
||||
const sessions = rows.map(row => ({
|
||||
id: row.id,
|
||||
date: row.date,
|
||||
muscle_groups: JSON.parse(row.muscle_groups)
|
||||
}));
|
||||
callback(null, sessions);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Get session by ID
|
||||
function getSessionById(id, callback) {
|
||||
const sql = 'SELECT * FROM sessions WHERE id = ?';
|
||||
db.get(sql, [id], (err, row) => {
|
||||
if (err) {
|
||||
callback(err, null);
|
||||
} else if (!row) {
|
||||
callback(null, null);
|
||||
} else {
|
||||
const session = {
|
||||
id: row.id,
|
||||
date: row.date,
|
||||
muscle_groups: JSON.parse(row.muscle_groups)
|
||||
};
|
||||
callback(null, session);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Create new session
|
||||
function createSession(id, date, muscleGroups, callback) {
|
||||
const sql = 'INSERT INTO sessions (id, date, muscle_groups) VALUES (?, ?, ?)';
|
||||
const muscleGroupsJSON = JSON.stringify(muscleGroups);
|
||||
|
||||
db.run(sql, [id, date, muscleGroupsJSON], function(err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
callback(null, { id, date, muscle_groups: muscleGroups });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Update existing session
|
||||
function updateSession(id, date, muscleGroups, callback) {
|
||||
const sql = 'UPDATE sessions SET date = ?, muscle_groups = ? WHERE id = ?';
|
||||
const muscleGroupsJSON = JSON.stringify(muscleGroups);
|
||||
|
||||
db.run(sql, [date, muscleGroupsJSON, id], function(err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else if (this.changes === 0) {
|
||||
callback(new Error('Session not found'));
|
||||
} else {
|
||||
callback(null, { id, date, muscle_groups: muscleGroups });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Delete session
|
||||
function deleteSession(id, callback) {
|
||||
const sql = 'DELETE FROM sessions WHERE id = ?';
|
||||
|
||||
db.run(sql, [id], function(err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else if (this.changes === 0) {
|
||||
callback(new Error('Session not found'));
|
||||
} else {
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Close database connection
|
||||
function closeDatabase() {
|
||||
db.close((err) => {
|
||||
if (err) {
|
||||
console.error('Error closing database:', err.message);
|
||||
} else {
|
||||
console.log('Database connection closed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getAllSessions,
|
||||
getSessionById,
|
||||
createSession,
|
||||
updateSession,
|
||||
deleteSession,
|
||||
closeDatabase
|
||||
};
|
||||
842
backend/package-lock.json
generated
Normal file
842
backend/package-lock.json
generated
Normal file
@@ -0,0 +1,842 @@
|
||||
{
|
||||
"name": "gym-tracker-back",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gym-tracker-back",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/accepts": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
|
||||
"integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-types": "^3.0.0",
|
||||
"negotiator": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz",
|
||||
"integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "^3.1.2",
|
||||
"content-type": "^1.0.5",
|
||||
"debug": "^4.4.0",
|
||||
"http-errors": "^2.0.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"on-finished": "^2.4.1",
|
||||
"qs": "^6.14.0",
|
||||
"raw-body": "^3.0.0",
|
||||
"type-is": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/bytes": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
|
||||
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bound": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
|
||||
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"get-intrinsic": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/content-disposition": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz",
|
||||
"integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "5.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/content-type": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
|
||||
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
||||
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cookie-signature": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
|
||||
"integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/depd": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/encodeurl": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
|
||||
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/etag": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz",
|
||||
"integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "^2.0.0",
|
||||
"body-parser": "^2.2.0",
|
||||
"content-disposition": "^1.0.0",
|
||||
"content-type": "^1.0.5",
|
||||
"cookie": "^0.7.1",
|
||||
"cookie-signature": "^1.2.1",
|
||||
"debug": "^4.4.0",
|
||||
"encodeurl": "^2.0.0",
|
||||
"escape-html": "^1.0.3",
|
||||
"etag": "^1.8.1",
|
||||
"finalhandler": "^2.1.0",
|
||||
"fresh": "^2.0.0",
|
||||
"http-errors": "^2.0.0",
|
||||
"merge-descriptors": "^2.0.0",
|
||||
"mime-types": "^3.0.0",
|
||||
"on-finished": "^2.4.1",
|
||||
"once": "^1.4.0",
|
||||
"parseurl": "^1.3.3",
|
||||
"proxy-addr": "^2.0.7",
|
||||
"qs": "^6.14.0",
|
||||
"range-parser": "^1.2.1",
|
||||
"router": "^2.2.0",
|
||||
"send": "^1.1.0",
|
||||
"serve-static": "^2.2.0",
|
||||
"statuses": "^2.0.1",
|
||||
"type-is": "^2.0.1",
|
||||
"vary": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/finalhandler": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz",
|
||||
"integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.4.0",
|
||||
"encodeurl": "^2.0.0",
|
||||
"escape-html": "^1.0.3",
|
||||
"on-finished": "^2.4.1",
|
||||
"parseurl": "^1.3.3",
|
||||
"statuses": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/forwarded": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/fresh": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
|
||||
"integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"math-intrinsics": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
"es-object-atoms": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/http-errors": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
|
||||
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"depd": "2.0.0",
|
||||
"inherits": "2.0.4",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "2.0.1",
|
||||
"toidentifier": "1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/http-errors/node_modules/statuses": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
||||
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ipaddr.js": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
||||
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/is-promise": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
|
||||
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz",
|
||||
"integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/merge-descriptors": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz",
|
||||
"integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.54.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
|
||||
"integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz",
|
||||
"integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-db": "^1.54.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/negotiator": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
|
||||
"integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.13.4",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
||||
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/on-finished": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
||||
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ee-first": "1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/parseurl": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/path-to-regexp": {
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz",
|
||||
"integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"forwarded": "0.2.0",
|
||||
"ipaddr.js": "1.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
|
||||
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/range-parser": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
||||
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/raw-body": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.1.tgz",
|
||||
"integrity": "sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"http-errors": "2.0.0",
|
||||
"iconv-lite": "0.7.0",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/raw-body/node_modules/iconv-lite": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz",
|
||||
"integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/router": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
|
||||
"integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.4.0",
|
||||
"depd": "^2.0.0",
|
||||
"is-promise": "^4.0.0",
|
||||
"parseurl": "^1.3.3",
|
||||
"path-to-regexp": "^8.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/send": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz",
|
||||
"integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.5",
|
||||
"encodeurl": "^2.0.0",
|
||||
"escape-html": "^1.0.3",
|
||||
"etag": "^1.8.1",
|
||||
"fresh": "^2.0.0",
|
||||
"http-errors": "^2.0.0",
|
||||
"mime-types": "^3.0.1",
|
||||
"ms": "^2.1.3",
|
||||
"on-finished": "^2.4.1",
|
||||
"range-parser": "^1.2.1",
|
||||
"statuses": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/serve-static": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz",
|
||||
"integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encodeurl": "^2.0.0",
|
||||
"escape-html": "^1.0.3",
|
||||
"parseurl": "^1.3.3",
|
||||
"send": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/setprototypeof": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
||||
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/side-channel": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
|
||||
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-list": "^1.0.0",
|
||||
"side-channel-map": "^1.0.1",
|
||||
"side-channel-weakmap": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-list": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
|
||||
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-map": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
|
||||
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-weakmap": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
|
||||
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-map": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/statuses": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
|
||||
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/toidentifier": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
||||
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/type-is": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz",
|
||||
"integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"content-type": "^1.0.5",
|
||||
"media-typer": "^1.1.0",
|
||||
"mime-types": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"license": "ISC"
|
||||
}
|
||||
}
|
||||
}
|
||||
16
backend/package.json
Normal file
16
backend/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "gym-tracker-back",
|
||||
"version": "1.0.0",
|
||||
"description": "Gym tracker application back-end",
|
||||
"license": "ISC",
|
||||
"author": "Roger Oriol",
|
||||
"type": "commonjs",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^5.1.0"
|
||||
}
|
||||
}
|
||||
140
backend/server.js
Normal file
140
backend/server.js
Normal file
@@ -0,0 +1,140 @@
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const db = require('./database');
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
// Middleware
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
// Validation helpers
|
||||
function isValidDate(dateString) {
|
||||
const regex = /^\d{4}-\d{2}-\d{2}$/;
|
||||
if (!regex.test(dateString)) return false;
|
||||
const date = new Date(dateString);
|
||||
return date instanceof Date && !isNaN(date);
|
||||
}
|
||||
|
||||
function isValidMuscleGroups(muscleGroups) {
|
||||
if (!Array.isArray(muscleGroups) || muscleGroups.length === 0) {
|
||||
return false;
|
||||
}
|
||||
const validGroups = ['Chest', 'Legs', 'Delts', 'Lats', 'Triceps', 'Biceps'];
|
||||
return muscleGroups.every(group => validGroups.includes(group));
|
||||
}
|
||||
|
||||
// API Routes
|
||||
|
||||
// GET /api/sessions - Fetch all sessions
|
||||
app.get('/api/sessions', (req, res) => {
|
||||
db.getAllSessions((err, sessions) => {
|
||||
if (err) {
|
||||
console.error('Error fetching sessions:', err);
|
||||
return res.status(500).json({ error: 'Failed to fetch sessions' });
|
||||
}
|
||||
res.json(sessions);
|
||||
});
|
||||
});
|
||||
|
||||
// POST /api/sessions - Create new session
|
||||
app.post('/api/sessions', (req, res) => {
|
||||
const { date, muscle_groups } = req.body;
|
||||
|
||||
// Validation
|
||||
if (!date) {
|
||||
return res.status(400).json({ error: 'Date is required' });
|
||||
}
|
||||
if (!isValidDate(date)) {
|
||||
return res.status(400).json({ error: 'Invalid date format. Use YYYY-MM-DD' });
|
||||
}
|
||||
if (!muscle_groups) {
|
||||
return res.status(400).json({ error: 'Muscle groups are required' });
|
||||
}
|
||||
if (!isValidMuscleGroups(muscle_groups)) {
|
||||
return res.status(400).json({
|
||||
error: 'Invalid muscle groups. Must be a non-empty array containing: Chest, Legs, Delts, Lats, Triceps, Biceps'
|
||||
});
|
||||
}
|
||||
|
||||
// Generate unique ID
|
||||
const id = uuidv4();
|
||||
|
||||
// Create session
|
||||
db.createSession(id, date, muscle_groups, (err, session) => {
|
||||
if (err) {
|
||||
console.error('Error creating session:', err);
|
||||
return res.status(500).json({ error: 'Failed to create session' });
|
||||
}
|
||||
res.status(201).json(session);
|
||||
});
|
||||
});
|
||||
|
||||
// PUT /api/sessions/:id - Update session
|
||||
app.put('/api/sessions/:id', (req, res) => {
|
||||
const { id } = req.params;
|
||||
const { date, muscle_groups } = req.body;
|
||||
|
||||
// Validation
|
||||
if (!date) {
|
||||
return res.status(400).json({ error: 'Date is required' });
|
||||
}
|
||||
if (!isValidDate(date)) {
|
||||
return res.status(400).json({ error: 'Invalid date format. Use YYYY-MM-DD' });
|
||||
}
|
||||
if (!muscle_groups) {
|
||||
return res.status(400).json({ error: 'Muscle groups are required' });
|
||||
}
|
||||
if (!isValidMuscleGroups(muscle_groups)) {
|
||||
return res.status(400).json({
|
||||
error: 'Invalid muscle groups. Must be a non-empty array containing: Chest, Legs, Delts, Lats, Triceps, Biceps'
|
||||
});
|
||||
}
|
||||
|
||||
// Update session
|
||||
db.updateSession(id, date, muscle_groups, (err, session) => {
|
||||
if (err) {
|
||||
if (err.message === 'Session not found') {
|
||||
return res.status(404).json({ error: 'Session not found' });
|
||||
}
|
||||
console.error('Error updating session:', err);
|
||||
return res.status(500).json({ error: 'Failed to update session' });
|
||||
}
|
||||
res.json(session);
|
||||
});
|
||||
});
|
||||
|
||||
// DELETE /api/sessions/:id - Delete session
|
||||
app.delete('/api/sessions/:id', (req, res) => {
|
||||
const { id } = req.params;
|
||||
|
||||
db.deleteSession(id, (err) => {
|
||||
if (err) {
|
||||
if (err.message === 'Session not found') {
|
||||
return res.status(404).json({ error: 'Session not found' });
|
||||
}
|
||||
console.error('Error deleting session:', err);
|
||||
return res.status(500).json({ error: 'Failed to delete session' });
|
||||
}
|
||||
res.status(204).send();
|
||||
});
|
||||
});
|
||||
|
||||
// Health check endpoint
|
||||
app.get('/health', (req, res) => {
|
||||
res.json({ status: 'ok' });
|
||||
});
|
||||
|
||||
// Start server
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server running on port ${PORT}`);
|
||||
});
|
||||
|
||||
// Graceful shutdown
|
||||
process.on('SIGINT', () => {
|
||||
console.log('\nShutting down gracefully...');
|
||||
db.closeDatabase();
|
||||
process.exit(0);
|
||||
});
|
||||
0
frontend/api.js
Normal file
0
frontend/api.js
Normal file
0
frontend/app.js
Normal file
0
frontend/app.js
Normal file
56
frontend/index.html
Normal file
56
frontend/index.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Gym tracker</title>
|
||||
<base href="/">
|
||||
<meta name="viewport"
|
||||
content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0">
|
||||
<meta name="description" content="">
|
||||
<meta name="keywords" content="">
|
||||
<meta name="author" content="">
|
||||
<meta name="application-name" content="">
|
||||
<meta name="theme-color" content="#33d">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<meta property="og:title" content="" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="" />
|
||||
<meta property="og:image" content="" />
|
||||
<link rel="canonical" href="" />
|
||||
<link rel="manifest" href="manifest.json">
|
||||
|
||||
<link rel="preload"
|
||||
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
|
||||
as="style" onload="this.onload=null;this.rel='stylesheet'">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: #fefefe;
|
||||
color: #222;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
padding: 1rem;
|
||||
line-height: 1.8;
|
||||
}
|
||||
</style>
|
||||
<link rel="preload" href="styles.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
|
||||
<noscript>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</noscript>
|
||||
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/service-worker.js');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="module" src="app.js"></script>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
0
frontend/styles.css
Normal file
0
frontend/styles.css
Normal file
0
nginx/nginx.conf
Normal file
0
nginx/nginx.conf
Normal file
Reference in New Issue
Block a user