/express-mongoose-rest-api

Starter project for a REST API with Node.js, Express & MongoDB

Primary LanguageJavaScript

Express Mongoose REST API

Starter project for a REST API with Node.js, Express & MongoDB

Prerequisites

Dependencies

Installation

$ git clone https://github.com/trionoputra/express-mongoose-rest-api.git
$ cd express-mongoose-rest-api
$ npm install
$ npm start

Routes

GET http://localhost:3000/user

Get all users.

  • Method: GET
  • URL: http://localhost:3000/user

POST http://localhost:3000/user

Create a new user.

  • Method: POST
  • URL: http://localhost:3000/user
  • Body:
{
  "id": "1",
  "name": "Trionoputra"
  "password": "123456"
}

GET http://localhost:3000/user/:userId

Get user with specific id.

  • Method: GET
  • URL: http://localhost:3000/user/1

PUT http://localhost:3000/user/:userId

Update entire user with specific id.

  • Method: PUT
  • URL: http://localhost:3000/user/1
  • Body:
{
  "name": "Triono putra"
  "password": "1234567890"
}

DELETE http://localhost:3000/user/:userId

Delete user with specific id.

  • Method: DELETE
  • URL: http://localhost:3000/user/1