Code Monkey home page Code Monkey logo

contact-management-system's Introduction

Contact Management API

a RESTful API that allows users to create, retrieve, update, and delete contact from a MongoDB database.

Features:

  • Environment, Typescript, Nodemon setup
  • MongoDB & Mongoose connect, Database creation
  • Controllers creation
  • Middlewares creation
  • Token based authentication (Bearer)
  • Postman testing
  • Create, Read, Update Delete (CRUD) operations
  • Encrypt and Decrypt phone number

Prerequisites

  • Node version 16.x

Cloning the Repository

clone the Repo

git clone [email protected]:sgatana/contact-management-system.git

Install packages using:

npm i / npm install
# or
yarn / yarn install

Folder Structure

dir/file description
src contains application files
src/index.ts root file / app configuration
src/config contains env variables and db connection
src/controllers house all the controllers needed for the application
src/helpers contains application files
src/middlewares contains middleware needed for the application
src/models contains db models and operations
src/routes contains logical set of routes
src/schemas contains model schemas

Routes

API's baseURL is localhost:8080/v1

Method path description
POST /auth/login logs in the user and generates access token
POST /auth/register register the user
GET (Authenticated) /contacts list all contacts
POST (Authenticated) /contacts create contacts
GET (Authenticated) /contacts/:id get contact by id
PATCH (Authenticated) /contacts/:id update contact
DELETE (Authenticated) /contacts/:id deletes contact

Db connection

Mongo Db connection has been initialized and mongo atlas uri has been provided in the env.ts file found in config folder Read more on how to create and connect to Mongo Atlas here

Run the development server using:

npm run dev
# or
yarn dev

To run the tests, run yarn test or npm run test

  • An admin user has been created to allow you interact with protected /users routes
  • Open http://localhost:8080 on your postman or API platform of your choice

Test account

  • use the following admin user details to log in and generate bearer token
{
    email: [email protected]
    password: admin
}

Endpoints

  • Contacts Management endpoints (v1/contacts)

    • contacts management endpoints are protected routes. One need to provide Bearer token in the authorization headers in order to interact with them

    • Methods

      Check swagger documentation to see the required payload, path and/or query params

      • POST v1/contacts - Creates contact
      • GET v1/contacts - Get all contacts
      • GET v1/contacts/:id - Get contact by id
      • PATCH v1/contacts:/id - Update a contact
      • DELETE v1/contacts:/id - Deletes a contact
  • User login endpoints (v1/auth/login)

    • allow user to login and generate access token to be used when interacting with contact management endpoints.

      • POST v1/auth/login - Logs in the user and generate access token.

Libraries

N.B check package.json file to all packages used by the API

contact-management-system's People

Contributors

sgatana 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.