This API provides access to a comprehensive workout management system. It allows users to create, retrieve, update, and delete workout plans and track their progress over time.
List the software and versions required to run your API.
Provide step-by-step instructions to set up the project locally.
# Clone the repository
git clone https://github.com/joshgarza/strengthtrainer-server
# Navigate to the project directory
cd strengthtrainer-server/
# Install dependencies
npm install
# Set up environment variables
rename example.env to .env
# Set up the database
# npx sequelize db:migrate
# Start the development server
npm run dev
This API uses JWT for authentication. When a new user registers or an existing user logs in, a JWT is issued. You must include this JWT token in the `Authorization` header of requests to protected endpoints.
Example:
Authorization: Bearer <your_token_here>
Detail the available API endpoints, their methods, and example requests/responses.
Register a User
POST /api/register
{
"username": "johndoe",
"password": "password123"
}
{
"message": "User registered successfully",
"token": "<jwt_token>"
}
Login a User
POST /api/login
{
"username": "johndoe",
"password": "password123"
}
{
"token": "<jwt_token>"
}
Get a Workout
GET /api/workouts/:id
{
"id": 1,
"name": "Leg Day",
"exercises": [...]
}
Create a Workout
POST /api/workouts
{
"name": "Leg Day",
"exercises": [...]
}
{
"id": 1,
"message": "Workout created successfully"
}
Add more endpoints following the same structure as needed.
List all environment variables required for the project and their descriptions.
PORT=3000
DATABASE_URL=your_database_url
JWT_SECRET=your_jwt_secret
Describe how errors are handled and what the typical error response looks like.
Example:
{
"error": "Invalid request parameters",
"message": "The 'name' field is required."
}
Explain how to run the tests for the API.
# Run unit and integration tests
npm test
# or
yarn test
Provide instructions for deploying the API to a live environment.
Example:
# Deploy to Heroku
heroku login
heroku create your-app-name
git push heroku main
heroku run npx sequelize db:migrate
Explain how others can contribute to the project.
Example:
git checkout -b feature/YourFeature
).git commit -m 'Add new feature'
).git push origin feature/YourFeature
).Include the license under which the project is released.
Example:
This project is licensed under the MIT License - see the LICENSE file for details.
Provide contact information for anyone needing further assistance.
Example:
If you have any questions, feel free to reach out at [your-email@example.com](mailto:your-email@example.com).
This README template provides a comprehensive structure for documenting your API. Customize it to fit the specifics of your project.
Feel free to copy and paste this template into your README file, and modify the content to suit your project's needs.