Giter Club home page Giter Club logo

contactsapi's Introduction

Contacts API by Jash Jasani

This is an api endpoint with basic CRUD operations in mongo db collection created with express. It is loosely coupled (dependency injection) server implementation that is the database can be changed in future.

Tech Stack

Server: Node, Express, Jsonwebtoken, MongoDb

API Reference

Get jwt token

  POST /login     
Body Type Description
username string Required. (by default jash123)
password string Required. (by default jash@1911)

Get all contacts

  GET /contacts    - token required in Header Authorization Bearer 
Query params Type Description
page Number Required. for pagination

Add contact

  POST /add         - token required in Header Authorization Bearer 
Body Type Description
contact string Required. Phone or mobile number
name string Required. Name of the person

Find contact

  POST /findcontact   - token required in Header Authorization Bearer 
Body Type Description
contact string Required. Phone or mobile number

Update contact

  POST /update       - token required in Header Authorization Bearer 
Body Type Description
contact string Required. Phone or mobile number
name string Required. Old name
newName string Required. New name

Delete a contact

  POST /delete       - token required in Header Authorization Bearer 
Body Type Description
contact string Required. Phone or mobile number
name string Required. Name

Database model methods

  • getContact(Contact)

takes in contact object, retruns a single contact or null

  • setContact(Contact)

method to add a contact to database, returns the added contact and its _id

  • getAllContacts(pageNumber,pageSize)

expects pageNumber and pageSize as a parameter

  • updateContact(contact, newName)

parameters = conatact number and the newName

  • deleteContact(Contact)

takes Contact object as input parameter

  • findExactContact(Contact)

it needs the exact same Contact object without _id

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

ACCESS_TOKEN - 64 bit hex string

Authors

Run Locally

Clone the project

  git clone https://github.com/jashjasani/ContactsApi

Go to the project directory

  cd my-project

Install dependencies

  npm install

Start the server

  node server.js

contactsapi's People

Contributors

jashjasani avatar

Watchers

 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.