dhanushkac / nodejs-mongodb-crud-app

This sample project explains how to create REST API using node.js with mongoDB. πŸƒ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NodeJS MongoDB Example CRUD app

This sample project explains how to create REST API using node.js with mongoDB. πŸƒ

Development

Create .env file in the root directory.

Add the mongoDB connection URI as DB_URI as follows.

DB_URI=<your url goes here>

Then install the dependencies.

npm install

Run with dev

This command executes with nodemon.

npm run dev

Endpoints

Fetch all books

GET /books

Fetch a book

GET /books/:bookId

Add a book

POST /books
{
        "rating": 4.9,
        "name": "The Hobbit X",
        "category": "Action",
        "bookId": "OLKA-1"
}

Update a book

PUT /books/:bookId
{
    "rating": 4.6
}

Delete a book

DELETE /books/:bookId

Fetch top books

GET /books/top


Developed with 🧑 by Dhanushka

About

This sample project explains how to create REST API using node.js with mongoDB. πŸƒ


Languages

Language:JavaScript 100.0%