Skip to content

mansiTT/express-crud-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Application

Simple in memory CRUD operations using express. #exprees #crud #mocha #joi #async await

How to run the service?

  1. Install Dependencies.
Using NPM
```
npm install
```
  1. Run Test Cases
Using NPM
```
npm test
```  
  1. Running Service
Using NPM
```
npm start
```  

API Description:

  1. ADD user URL : http://localhost:3003/user/role Method Type : POST Request Body :
{
  "firstname": "Alexandar",
  "lastname": "King",
  "email": "[email protected]",
  "role": "SUPER ADMIN",
  "id" : "7878"
}

Response Body (200) :

{
    "code": 200,
    "message": "SUCCESS"
}

Response Body (400) Bad Request :

{
    "code": 400,
    "message": "\"firstname\" is required"
}

// GET USER

URL : http://localhost:3003/user/role/:email Method Type : GET

Response Body (200) with data:

{
    "code": 200,
    "message": "SUCCESS",
    "data": {
        "firstname": "Alexandar",
        "lastname": "King",
        "email": "[email protected]",
        "role": "SUPER ADMIN",
        "id": "7878"
    }
}

Response Body (200) Wihtout Data :

{
    "code": 200,
    "message": "NO RECORD FOUND"
}

// Delete User

URL : http://localhost:3003/user/role/:email Method Type : Delete

Response Body (200) :

{
    "code": 200,
    "message": "Records has been removed."
}

// Update User Details

URL : http://localhost:3001/role/:email Method Type : PUT

Request Body :

{
  "first_name": "lskol",
  "last_name": "Allen",
  "email": "[email protected]",
  "role": "ADMIN"
}

// Get All Users

URL : http://localhost:3003/users Method Type : POST

Response Body :

[
    {
        "id": "1566034002186",
        "firstname": "Mansi",
        "lastname": "shs",
        "email": "[email protected]",
        "role": "2"
    },
    {
        "id": "1566034002186",
        "firstname": "Mansi",
        "lastname": "shs",
        "email": "[email protected]",
        "role": "2"
    }
]

Folder Structure Conventions

===============================

├── cache # Caching files ├── controllers # Controllers
├── joi-validtor # API Request Body Schema Validation code
├── routes # API Routes : Endpoint config
├── services # Service File, business logic
├── tests # Test Cases using Chai
├── utils # Utility, Constants files ├── app.js
├── package.json └── README.md

About

Boilerplate code for express to perform in memory CRUD operations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors