Code Monkey home page Code Monkey logo

sms-service's Introduction

Application to send SMS via Twillio service.

TODO

  • Brute force protect, it means it will possible to send message to one number not more often than in a certain period. Env setup should be provided.
  • Validate number endpoint
  • Webhook endpoint for Twilio
  • history url, it could be REST GET endpoint or graphql
  • UI for managing numbers (for huge amount of message > 250 per day)
  • history free mode (without DBs connected)

Description

Sms-service used postgres and redis to store data. Application saves history of all SMS which was sent or felt. Format and validate message is available. Also guard against brute force in development.

Dependencies

Databases required to provide service working:

  • PostgreSQL
  • Redis

It should running local, inside another Docker container, or on external server. For postgres you should create DB. If you have postgres and redis running you should provide HOST name, PORT and other data to connect in environment. Details about environment are below. Also you should have Twilio account.

Twilio

For sending message you should have Twilio account. You should provide your account SID and SECRET key to make service working. Also number required.

All available environment

NODE_ENV (default: 'development')
PORT (default: 80)
PG_DB
PG_USER
PG_PASSWORD
PG_HOST (default: 'localhost')
PG_PORT (default: '5432')
REDIS_HOST (default: 'localhost')
REDIS_PORT (default: '6379')
REDIS_PASSWORD
TW_SID
TW_TOKEN
TW_NUMBER

commands to start

npm run db:migrate:prod - reinitialize DB (drop and recreate)
npm run db:start:prod - initialize DB (just create)
npm run start:prod - start server

To make service working you should make first start with npm run db:start:prod command to initialize DB, after that you should restart container with npm run start:prod command to make service running. If you want reinitialize your DB npm run db:migrate:prod command available.

logs

sudo docker exec -it [ID] tail -f logs/info.log
sudo docker exec -it [ID] tail -f logs/error.log
[ID] - id or name container

URLs

Github Repo
Swagger API Documentation
Docker Cloud Repo

docker-compose

Example part of valid docker compose file for sms service:

sms-service:
    image: appshop/sms-service
    depends_on:
      - postgres
      - redis
    environment:
      NODE_ENV: production
      PG_DB: db_name
      PG_USER: user
      PG_PASSWORD: 12345678
      PG_HOST: postgres
      REDIS_HOST: redis
      TW_SID: AC5488852a6a3b420275745ccd4c7c33a9
      TW_TOKEN: 7g397g23a3eg0e9a38ef08faa94a4g0a
      TW_NUMBER: +14444444444
    command:
      ["npm", "run", "start:prod"]
    networks:
      - network

sms-service's People

Contributors

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