Code Monkey home page Code Monkey logo

multiple-email-providers's Introduction

Multiple Email Providers

typescript nodejs

HTTP Based API that sends emails through different providers to prevent downtime.

Technologies

  • NodeJS 12
  • Typescript
  • ExpressJS

I chose this stack because it works well for this type of microservices and I'm also familiar with it. I like how the language (Javascript/Typescript) and platform (NodeJS) evolved over the past few years. There are also mature libraries / frameworks by now and the community keeps growing. It also has better developer experience compared to technologies like Java.

ExpressJS is the most popular micro framework for NodeJS, but I could also have used Koa or something more oriented to building APIs like Hapi.

Typescript is a big improvement to the stack because it adds robustness and mantainability to the application. It may be harder to setup but it improves the dx: makes the code easier to read, write (better autocomplete) and refactor, besides adding documentation.

Check technical / architectural decisions document for more details

Development

  1. Install dependencies
npm i
  1. This project uses dotenv so you'll need to create an .env file with the configurtion. Use .env.example as reference.

Note: provider number defines priority

  1. Start the server in dev mode
npm run dev

Run the application locally

Using docker and docker-compose you can easily recreate the environment:

  • NodeJS server
  • Swagger UI
  • PostgreSQL
  1. Open docker-compose.yml and edit the env variables accordingly.

Note: provider number defines priority

  1. Install dependencies and build the app
npm i
npm run build
  1. Start the application
docker-compose up

The application is exposed on port http://localhost:3000 by default and swagger ui on http://localhost:9999

Run tests

The tests are implemented in jest. To run them:

npm test

Code style and linting

Code style is enforced with prettier and linting is done by tslint. To run it manually:

npm run lint

API Documentation

OpenAPI was used to document the API. It is exposed on http://localhost:3000/api-docs to be consumed by swagger-ui

Status endpoints

Two endpoints are exposed as reference:

  • /status/health - to check availability
  • /status/config - to expose the config

multiple-email-providers's People

Contributors

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