Skip to content

Latest commit

 

History

History
108 lines (66 loc) · 1.29 KB

README.md

File metadata and controls

108 lines (66 loc) · 1.29 KB

rest_Api

This repo is about how to create a rest API for beginners using MVC pattern.

Tech Stack

Database: Mongodb

Server: Node, Express, Mongoose

Run Locally

Clone the project

  git clone https://github.com/B-chandru/rest_Api.git

Go to the project directory

  cd rest_Api

Install dependencies

  npm install

Start the server

  npm run dev

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

PORT=5000

MONGODB=mongodb://localhost:27017/restapi

API Reference

Get all items

   http://localhost:5000/app/

Get items by id

   http://localhost:5000/app/:id

post

   http://localhost:5000/app/

for post request the json formate should be like this :

  
{
    "title":"my first api",
    "content":"how to create an api"
}

Put

  PUT http://localhost:5000/app/:id

if the put request is successful then you get this as a response

  {
  "msg": "updated the msg"
   }

Delete

  DELETE  http://localhost:5000/app/:id

if the delete request is successful then you get this as a response

 
{
  "msg": "deleted the msg"
}