Coder Social home page Coder Social logo

phonebook's Introduction

Phonebook API

Setup

# install dependencies
$ npm install # Or yarn install

# Add env variables.
- Create a .env file with the contents in the .env-sample file

# serve with hot reload at localhost:3000
$ yarn watch

RESTFUL PHONEBOOK API

AUTH API endpoints

1. Register User
  • URL:

    • /api/v1/auth/register
  • METHOD:

    • POST
  • DATA FORMAT

    • application/json
  • PAYLOAD:

    • email
    • password
    • firstName
    • lastName
  • SUCCESS:

    • status code 201
    • content {"success": "user created successfully", "token": "token_example"}
  • ERROR:
    • status code 400
    • content OR
    • status code 409
2. Authenticate User
  • URL:

    • /api/v1/authenticate
  • METHOD:

    • POST
  • DATA FORMAT

    • application/json
  • PAYLOAD:

    • email
    • password
  • SUCCESS:

    • status code 200
    • content {"success": "User authenticated successfully", "token": "token_example"}
  • ERROR:
    • status code 400
    • content

Phonebook APIs (PROTECTED WITH JWT TOKEN)

1. Create contact
  • URL:

    • /api/v1/contact/
  • METHOD:

    • POST
  • DATA FORMAT

    • application/json
  • PAYLOAD:

    • firstName
    • lastName
    • phone
    • company
    • email
    • country
  • SUCCESS:

    • status code 201
    • content { "success: "Contact created successfully" "contact": {} }
  • ERROR:
    • status code 400 OR
    • status code 403
2. Read Contact
  • URL:

    • /api/v1/contacts/
    • /api/v1/contact/:contact-id
  • METHOD:

    • GET
  • DATA FORMAT

    • application/json
  • PARAMETERS:

    • contact-id
  • SUCCESS:

    • status code 200

    • content

       {
           "contact": {}
       }
      

OR

  • content

       {
            contacts": [
                { },
                { }
            ]
       }
    
  • ERROR:

    • status code 400

    OR

    • status code 404

OR

  • status code 403

3. Update Contact

  • URL:

    • /api/v1/contact/:contact-id
  • METHOD:

    • PATCH
  • DATA FORMAT

    • application/json
  • PAYLOAD:

    • firstName
    • lastName
    • phone
    • company
    • email
    • country
  • SUCCESS:

    • status code 200

    • content

       {
           "success": "Contact updated successfully"
           "contact": { }
       }
      
  • ERROR:

    • status code 400 OR
    • status code 403 OR
    • status code 404

4. Delete Contact

  • URL:
    • /api/v1/contact/:contact-id
  • METHOD:
    • DELETE
  • DATA FORMAT
    • application/json
  • REQUIRED:
    • contact-id
  • SUCCESS:
    • status code 204
  • ERROR:
    • status code 400 OR
    • status code 403 OR
    • status code 404

ERRORS

400: { error: ${validation errors} }

401: { error: "User not authorized" }

404: { error: "${resource} not found" }

409: { error: "${resource} already exists" }

500: { error: "server error" }

phonebook's People

Contributors

rnkimani avatar

Watchers

Ridge Kimani 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.