Skip to content

DevM7mdAli/dummy-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DummyAPI

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.

Prerequisites

  • Node.js
  • MongoDB

Installation

  1. Clone the repository:

    git clone https://github.com/DevM7mdAli/dummy-api.git
    cd dummy-api
  2. Install dependencies:

    npm install
  3. Create a .env file in the root directory and add your MongoDB URI:

    MONGODB_URI=your_mongodb_uri
    PORT=3000

Running the API

To start the server, run:

npm start

For development mode with automatic restarts, run:

npm run dev

The server will be running at http://127.0.0.1:3000/.

API Endpoints

Get All Posts

  • URL: /api/post
  • Method: GET
  • Description: Retrieves all posts.

Get Single Post

  • URL: /api/post/{id}
  • Method: GET
  • Description: Retrieves a single post by ID.

Insert Post

  • URL: /api/post
  • Method: POST
  • Description: Inserts a new post.

Update Post

  • URL: /api/post/{id}
  • Method: PATCH
  • Description: Updates an existing post by ID.

Delete Post

  • URL: /api/post/{id}
  • Method: DELETE
  • Description: Deletes a post by ID.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors