This is a simple RESTful API for managing contacts in a phonebook. It allows you to perform CRUD (Create, Read, Update, Delete) operations on contacts.
To get started with this API, follow the steps below:
- Install Node.js and npm if you haven't already.
- Clone this repository to your local machine.
- Install dependencies by running
npm install
. - Set up a MongoDB database and obtain the connection URI.
- Create a
.env
file in the root directory and add your MongoDB URI asDB_URI
. - Start the server by running
npm run dev
. - The server will start running on http://localhost:8000 by default.
- GET /api/contacts: Get all contacts.
- GET /api/contacts/:id: Get a single contact by ID.
- POST /api/contacts: Create a new contact.
- PUT /api/contacts/:id: Update a contact by ID.
- DELETE /api/contacts/:id: Delete a contact by ID.
Request Body:
{
"name": "John Doe",
"phone": "123-456-7890"
}