Skip to content

piyushtnk/rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS + Express Server with REST API | [BETA - v1.3.10]

!Important: "You may see database specified error also - it'll turned off when it's goes for public launch."

An easy way to get started with a Express server offering a REST API with Node.js.

Features

  • Babel 7
  • Environment Variables
  • Express
  • REST API

Requirements

Installation

  • Clone this repository.
  • cd rest-api
  • npm install
  • npm start
  • Change port in .env file if you need.

GET Routes

POST Routes

PUT Routes

DELETE Routes

Beyond GET Routes

CURL

  • Get all of the users with:
    • curl -X GET -H "Content-Type:application/json" http://localhost:3000/users -d
  • Get a single user with:
    • curl -X GET -H "Content-Type:application/json" http://localhost:3000/users/1
  • Delete a user with:
    • curl -X DELETE -H "Content-Type:application/json" http://localhost:3000/users/1

Postman

Status & Results - When you hit the endpoint:

  • LOGIN response: { "id": 1, "username": "admin", "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNTc3MDkxOTQzLCJleHAiOjE1NzcwOTU1NDN9.xOPd4WqAT_AqtG5yyBaI8KQrjifnpQN0FIB1Otj7st0" }

  • UPDATE records result - (While using any update endpoints): { "status": true, "code": 200, "message": "success", "data": { "fieldCount": 0, "affectedRows": 1, "insertId": 0, "info": "Rows matched: 1 Changed: 1 Warnings: 0", "serverStatus": 2, "warningStatus": 0, "changedRows": 1 } }

  • DELETE response: { "status": true, "code": 200, "message": "success", "data": { "fieldCount": 0, "affectedRows": 0, "insertId": 0, "info": "", "serverStatus": 2, "warningStatus": 0 } }

Releases

No releases published

Packages

No packages published