Skip to content

malmike/SMSApplication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMSApplication

CircleCI Maintainability Test Coverage

SMS Application is an API that allows for the sending and receiving of messages. It is built using NodeJS, express, mongodb and typescript.

Requirements

In order to run this project locally you would need to have:

  • Node (Best to install v10.4.0). You can use NVM to install and manage node versions on your machine
  • MongoDB (For this project I used a docker image of mongoDB.)
  • Docker (if you plan to setup mongoDB to run in a docker image)
  • Yarn - After installing node install Yarn globally by running
npm -g install yarn

Setting up MongoDB to run in docker

You can run a docker image of mongo DB using docker run -p 27017:27017 mongo:3.4.20-jessie This command will download the specified mongo image if it does not exist locally and run the image. For this case am running the image mongo:3.4.20-jessie but you can get a list of mongo images here. The -p 27017:27017 specifies that the running image is being exposed on port 27017

Setup

  1. Clone the repository
    git clone https://github.com/malmike/SMSApplication.git
    
  2. Enter the directory and install the project dependencies
    cd SMSApplication
    yarn install
    
  3. Rename sample.env to .env
    mv sample.env .env
    
  4. Start mongodb service.
    • If you install mongodb locally run
      mongod
      
      If you require authentication
      sudo mongod
      
    • If you setup mongodb to run in docker then just ensure that the image is running
      docker container ls
      
      If the image is not running then run the command
      docker run -p 27017:27017  mongo:3.4.20-jessie
      
    Ensure that the .env file contains the value DB_URI=mongodb://localhost:27017/smsapplication
  5. Starting the application
    yarn start-dev
    
    The development environment is setup to allow live reloading using nodemon
  6. You can access the application in the browser
    http://localhost:1337
    
    The API uses swagger for documentation and this can be accessed at
    http://localhost:1337/api-docs/
    

Testing

To execute the applications tests run

yarn test

To execute tests with coverage run

yarn test-coverage

Endpoints

TYPE API ENDPOINT DESCRIPTION HEADERS PAYLOAD
POST /registerUser Creates a user or signs in a existing user content-type: applicaton/json
      {
        "name": "string",
        "phone_number": "string
      }
      
GET /getUser Gets logged in user content-type: applicaton/json
x-access-token: token
POST /addContact Adds a contact to signed in user content-type: applicaton/json
x-access-token: token
      {
        "contact_name": "string",
        "contact_phone_number": "string"
      }
      
GET /getContacts Gets all contacts for signed in user content-type: applicaton/json
x-access-token: token
DELETE /deleteContact/{phone_number} Delete contact from signed in user content-type: applicaton/json
x-access-token: token
POST /sendSms Send sms from signed in user to contact content-type: applicaton/json
x-access-token: token
      {
        "receiver_phone_number": "string",
        "message": "string"
      }
      
GET /getSms/{phone_number} Get SMSs sent from contact to signed in user content-type: applicaton/json
x-access-token: token
PUT /updateStatus Update the read status of an SMS message thread content-type: applicaton/json
x-access-token: token
      {
        "message_thread": "string"
      }
      

About

This is an sms application built using NodeJS, Express and MongoDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published