Skip to content

psnavega/microsservice-send-communication

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

Description

Nest framework TypeScript starter repository.

Is a microsservice ready for production, this structure were developed as multiprovider and multiple sender. Nowadays the app count with sender email and sender sms

More details and docs here: aqui

Installation

$ npm install

Running the app

# development
$ npm start

# watch mode
$ npm start:dev

# production mode
$ npm start:prod

Test

# unit tests
$ npm test

# e2e tests
$ npm test:e2e

# test coverage
$ npm test:cov

Running with Docker (Recommended)

You will need to have Docker and Docker Compose installed on your machine, as well as availability on ports 3306 and 3010.

Finally, there is an .env.example file in the repository for development purposes. Remove the .example extension, leaving only .env

After that, run the following command at the root of the project:

Running this script

$ cp .env.example .env
$ docker-compose up

Folders architecture

This repository will be organized by context, which means that all functionalities will be separated in the folder architecture based on their function, execution, or purpose of the service.

  • dist : Files generated to prod environment after build process;
  • node_modules : all dependencies installed on project (Docker already install it);
  • src: Source code
    • example (context)
      • application: Folder containing classes, modulers and controllers of section this app;
      • data: Folder containing classes to manipulate data or implement use cases;
      • domain: Folder containing all domain abstractions as well as their implementation.;
    • infra: Folder containing classes to receive data from external api's, which connect with database, etc.
    • shared: Folder containig shared resource, which means resources used more than one context
  • test: Folder to implement all tests - unit and integration when elegible;


First request

Example

POST localhost:3000/api/email/send

Expected response

{
    "id": "646ceda9cc7ba242a2b79b2c",
    "message": "Comunicação agendada com sucesso"
}

Contribution

  • Open a new branch like gitflow. Example: `feature/what-your-branch-does`.
  • When finished, open a Merge Request (MR) to the `develop` branch and handle the card on the Asana/Jira board to advise that you have finished and wait for a reviewer.

Executing testing within Docker

Once the container is up and running, execute the following command within the container application shell

yarn test

Coverage

yarn test:cov

It is strongly recommended that every resource added to this microservice be properly tested - unit and integration when applicable

Considerations

Ensure that all mandatories envs were set on .env.example when running

Mandatory environments will be below a region in .env.example/.env

To test send emails will be necessary have account on mailtrap, just set authentications on env on the specific field and zenvia key

Powered

Powered by Patrick Navega