A simple REST API capable of CRUD {create, read, update, delete}operations on a "person" resource that interfaces with a MongoDB database. It allows you to add, retrieve, update, and delete person records.
Before you begin, ensure you have met the following requirements:
- Node.js and npm installed on your machine.
- MongoDB installed and running locally or access to a MongoDB instance.
- Git (optional, for cloning the repository).
- clone project repository:
git clone https://github.com/Computewell/HNG-x.git
-
Navigate to the project directory:
cd hng-x-2
Install dependencies:
```bash
npm install
Create a .env
with the values:
MONGO_URI=<replace-with-mongodb-connection-string>
PORT=5000
Start up server:
npm run dev
Here is the UML (Unified Modeling Language) diagram representing the structure and relationships of this API's classes and models:
Route | Description |
---|---|
GET /api/:id |
Fetch a user from the database |
POST /api |
Create a new user |
PUT /api/:id |
Update a user |
DELETE /api/:id |
Delete a user |
-
Create a new person:
POST /api Request Body: { "name": "Ololade Akinloye" }
-
Retrieve details of a person:
GET /api/:id
-
Update details of an existing person:
PATCH /api/:id Request Body: { "name": "Updated Name" }
-
Remove a person:
DELETE /api/:id
To test the API endpoints, you can use tools like Postman or write automated tests using testing libraries like Mocha and Chai. Ensure that you have the necessary testing environment set up.