Giter VIP home page Giter VIP logo

devscontact-express's Introduction

Devscontact-Express


A REST API server implementation built on top Node.js and Express.js with Mongoose.js for MongoDB (MLAB) integration. Access control for selected Routes using Passport.js.

Details The Server provides access to CRUD operations for database of Developers assigned to Categories

Requirements


You need to have NodeJs installed on your machine. The Server was written on Nodejs v8.11.4

Installing Project


  1. Yarn
  2. Setup Database in your Env file
  3. Make Env file - example gist

Run Server and Tests


  1. npm start -- Port 3000 by default
  2. npm test

End Points


Contacts

  1. URL /contact Methods

    1. GET All Contacts (Returns a List/Array) - Open Access without Token

      Response [ { "_id": "5c0fbd14f7d2f0361df73507", "firstname": "Samnuel", "lastname": "Victor", "email": "[email protected]", "phone": 8062239670, "category": { "_id": "5c07bed0a55cd01aecbc70f8", "name": "Full Stack" }, "createdAt": "2018-12-11T13:35:16.160Z", "updatedAt": "2018-12-17T14:48:04.837Z" } ]

    2. POST (Add a new Contact) - Secured Header = "x-auth-token" : "token from login"

      Body

      { "category": "category_id from an already created category", "firstname": "usrfirstname", "lastname": "usrlastname", "email": "[email protected]"", "phone": 87677766 }

    3. PUT (Update created contact) - Secured

      Header = "x-auth-token" : "token from login" Body

      { "id": "contact id" "category": "category_id from an already created category", "firstname": "usrfirstname", "lastname": "usrlastname", "email": "[email protected]"", "phone": 87677766 }

    4. DELETE (Remove and exist Contact) - Secured Header = "x-auth-token" : "token from login" Body

      { "id": "contact id" }

  2. URL /contact/contactId - Secured Method = GET

    Header = "x-auth-token" : "token from login"

Categories

  1. URL /categories Methods

    1. GET All Categories (Returns a List/Array) - Open Access without Token

      Response [ { "_id": "5c07bed0a55cd01aecbc70f8", "name": "Full Stack" } ]

    2. POST (Add a new Category) - Secured Header = "x-auth-token" : "token from login"

      Body {"name" : "Category name"}

    3. PUT (Update created contact) - Secured Header = "x-auth-token" : "token from login"

      Body {"id": "category id", "name" : "Category name"}

    4. DELETE (Remove and exist Contact) - Secured Header = "x-auth-token" : "token from login"

      Body {"id": "category id"}

  2. URL /category/categoryId - Secured

Method = GET - Get a single result

Authentication

  1. URL /auth/register

    Params { "email" : "[email protected]", "password" : "password@1", "firstname": "usrfirstname", "lastname" : "usrlastname" }

    Success Response { "message": "User registered", "data": { "email": "[email protected]", "firstname": "usrfirstname", "lastname": "usrlastname", "_id": "5c214edbbbb919542273221e", "createdAt": "2018-12-24T21:25:47.794Z" } }

    Error Response { "message": "User with email ([email protected]) already exists" }

  2. URL /auth/login

    Params { "email" : "[email protected]", "password" : "password@1" }

    Success Response {"token": "token value"}

    Error Response { "message": { "errors": { "email or password": "is invalid" } } }

devscontact-express's People

Contributors

victorighalo avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.