This is a simple REST API built with Express.js that performs CRUD operations on a "person" resource, using MongoDB as the database.
Before you begin, ensure you have met the following requirements:
- Node.js and npm installed on your machine.
- MongoDB installed and running locally.
-
Clone the repository:
git clone https://github.com/JesusOfLagos/HNG-Stage-Two.git
-
Navigate to the project directory:
cd HNG-Stage-Two
-
Install dependencies:
npm install
-
Start the server
npm start
- Create a new Person:
POST /api
a. Request Body:
{
"name": "John Doe"
}
b. Response Body
{
"id": "icidoi988988v9iu"
"name": "John Doe"
}
-
Get A Person By Id
GET /api/:id
a. Response Body
{
"name": "John Doe"
}
-
Update A Person By Id
PUT /api/:id
a. Request Body
{
"name": "John Doe"
}
b. Response Body:
{
"message": "Person Updated Successfully"
}
-
Delete A Person By Id
DELETE /api/:id
a. Response Body
{
"message": "Person Deleted Successfully"
}