A RESTful API for managing users, allowing operations to create, retrieve, update, and delete user information.
- Clone the repository:
git clone <https://github.com/MaxintokE/Lightweight.git>
- Navigate to the project directory:
cd <https://github.com/MaxintokE/Lightweight>
- Run the following command to install dependencies:
npm install
- Start the server:
node index.js
- The API will be available at
http://localhost:3000
.
- URL:
/api/users/:id
- Method:
GET
- URL Params:
id=[integer]
- Success Response:
- Code: 200
- Content:
{ "id": 1, "name": "John", "email": "[email protected]" }
- Error Response:
- Code: 404
- Content:
{ "message": "User not found" }
- URL:
/api/users
- Method:
POST
- Body Params:
name=[string]
email=[string]
- Success Response:
- Code: 201
- Content:
{ "id": 2, "name": "Jane", "email": "[email protected]" }
- Error Response:
- Code: 400
- Content:
{ "message": "Invalid input" }
- URL:
/api/users/:id
- Method:
PUT
- URL Params:
id=[integer]
- Body Params:
name=[string]
(optional)email=[string]
(optional)
- Success Response:
- Code: 200
- Content:
{ "id": 1, "name": "John Updated", "email": "[email protected]" }
- Error Response:
- Code: 404
- Content:
{ "message": "User not found" }
- URL:
/api/users/:id
- Method:
DELETE
- URL Params:
id=[integer]
- Success Response:
- Code: 204
- Error Response:
- Code: 404
- Content:
{ "message": "User not found" }
- The API uses standard HTTP status codes to indicate the success or failure of an API request.
- Common error responses include:
- 400 Bad Request: Returned when the request is invalid or missing parameters.
- 404 Not Found: Returned when the requested resource does not exist.
- 500 Internal Server Error: Returned when there is an unexpected error on the server side.
{
"message": "An error occurred"
}
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -m 'Add some AmazingFeature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a pull request.
For questions or suggestions, please contact:
- Name: [[email protected]]
- GitHub: [https://github.com/Aureliaotty)