DummyAPI is a simple Node.js API that allows you to perform CRUD operations on posts. It uses MongoDB as the database and Mongoose for object data modeling.
- Node.js
- MongoDB
-
Clone the repository:
git clone https://github.com/DevM7mdAli/dummy-api.git cd dummy-api -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and add your MongoDB URI:MONGODB_URI=your_mongodb_uri PORT=3000
To start the server, run:
npm startFor development mode with automatic restarts, run:
npm run devThe server will be running at http://127.0.0.1:3000/.
- URL:
/api/post - Method:
GET - Description: Retrieves all posts.
- URL:
/api/post/{id} - Method:
GET - Description: Retrieves a single post by ID.
- URL:
/api/post - Method:
POST - Description: Inserts a new post.
- URL:
/api/post/{id} - Method:
PATCH - Description: Updates an existing post by ID.
- URL:
/api/post/{id} - Method:
DELETE - Description: Deletes a post by ID.