API built with Node.js, Express, and MongoDB to manage investors.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory with the following content:DATABASE_URL=mongodb://localhost:27017/yourDatabaseName
-
Start the server:
node server.js
The server will start on port 3000.
Use tools like Postman or REST Client to interact with the API.
- URL:
/investors
- Method:
GET
- Response:
[ { "_id": "unique_id", "name": "Investor Name", "investingToCompany": "Company Name", "investingDate": "2023-01-01T00:00:00.000Z" }, ... ]
- URL:
/investors/:id
- Method:
GET
- Response:
{ "_id": "unique_id", "name": "Investor Name", "investingToCompany": "Company Name", "investingDate": "2023-01-01T00:00:00.000Z" }
- URL:
/investors
- Method:
POST
- Request Body:
{ "name": "Investor Name", "investingToCompany": "Company Name" }
- Response:
{ "_id": "unique_id", "name": "Investor Name", "investingToCompany": "Company Name", "investingDate": "2023-01-01T00:00:00.000Z" }
- URL:
/investors/:id
- Method:
PATCH
- Request Body:
{ "name": "Updated Name", "investingToCompany": "Updated Company" }
- Response:
{ "_id": "unique_id", "name": "Updated Name", "investingToCompany": "Updated Company", "investingDate": "2023-01-01T00:00:00.000Z" }
- URL:
/investors/:id
- Method:
DELETE
- Response:
{ "message": "Deleted Investor" }
Create a .env
file in the root directory with the following content:
DATABASE_URL=mongodb://localhost:27017/yourDatabaseName