Skip to content

Aureliaotty/API_assignment-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Management API

A RESTful API for managing users, allowing operations to create, retrieve, update, and delete user information.

Table of Contents

Setup

  1. Clone the repository:
    git clone <https://github.com/MaxintokE/Lightweight.git>
  2. Navigate to the project directory:
    cd <https://github.com/MaxintokE/Lightweight>
  3. Run the following command to install dependencies:
    npm install
  4. Start the server:
    node index.js
  5. The API will be available at http://localhost:3000.

API Endpoints

Get User by ID

  • URL: /api/users/:id
  • Method: GET
  • URL Params: id=[integer]
  • Success Response:
  • Error Response:
    • Code: 404
    • Content:
      { 
        "message": "User not found" 
      }

Create User

  • URL: /api/users
  • Method: POST
  • Body Params:
    • name=[string]
    • email=[string]
  • Success Response:
  • Error Response:
    • Code: 400
    • Content:
      { 
        "message": "Invalid input" 
      }

Update User

  • URL: /api/users/:id
  • Method: PUT
  • URL Params: id=[integer]
  • Body Params:
    • name=[string] (optional)
    • email=[string] (optional)
  • Success Response:
  • Error Response:
    • Code: 404
    • Content:
      { 
        "message": "User not found" 
      }

Delete User

  • URL: /api/users/:id
  • Method: DELETE
  • URL Params: id=[integer]
  • Success Response:
    • Code: 204
  • Error Response:
    • Code: 404
    • Content:
      { 
        "message": "User not found" 
      }

Error Handling

  • 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.

Example Error Response

{ 
  "message": "An error occurred" 
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a pull request.

Contact

For questions or suggestions, please contact:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published