Giter VIP home page Giter VIP logo

otaviolemos / thewisedev-mailing Goto Github PK

View Code? Open in Web Editor NEW
484.0 9.0 86.0 807 KB

theWiseDev | API for a squeze page to register users on a mailing list and to email them a bonus (written in Node.js and TypeScript in a Clean Architecture). This project can be used as a reference implementation of the Clean Architecture with Node.js and TypeScript.

Home Page: http://www.thewisedev.com.br

JavaScript 2.08% TypeScript 97.92%
clean-architecture tdd ddd nodejs typescript

thewisedev-mailing's Introduction

theWiseDev | API for a squeze page to register users on a mailing list and to email them a bonus (written in Node.js and TypeScript in a Clean Architecture)

This is an API used in the backend of the landing page of theWiseDev platform (http://www.thewisedev.com.br).

It is a basic squeeze page where the user can be registered on the mailing list and receive an e-mail with a bonus.

The API was developed using concepts from Clean Architecture, Domain-Driven Design, Test-Driven Development, Continuos Refactoring, and Atomic Commits.

To run this project you will need to create a .env file at the root of your project with values for the following environment variables:

  • EMAIL_HOST
  • EMAIL_PORT
  • EMAIL_USERNAME
  • EMAIL_PASSWORD
  • MONGO_URL
  • PORT

The EMAIL_* variables are used to send the e-mail to the registered user; MONGO_URL is where your MongoDB is located (you can also create other implementations for the UserRepository for other specific databases if you like; the use cases were developed independent from specific database implementations); and PORT is the port where your API will run.

We believe this project can be used as a reference implementation of the Clean Architecture with Node.js and TypeScript.

Copyright © 2020 theWiseDev

thewisedev-mailing's People

Contributors

otaviolemos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thewisedev-mailing's Issues

Dúvida: O papel de sua entidade User é ser apenas um validador?

@otaviolemos, parabéns pelo código. Estou a dias o estudando e aprendendo bastante. Obrigado por compartilhar.

Eu gostaria de entender porque você persiste um UserData ao invés do User. É alguma limitação do mongo? Eu entendi sua entidade User como uma classe validadora. É isto mesmo? Poderia me explicar por favor?

Abraços.

Checar nome de usuário preenchido apenas com espaços em branco

Ao criar o teste abaixo, ele não passa, pois espaços em branco não são removidos do nome do usuário:

test('should not create user with invalid name (only blank spaces)', async () => {
    const name = '   '
    const user = User.create({ name: name, email: '[email protected]' })
    expect(user).toEqual(left(new InvalidNameError(name)))
  })

Alterar o método validate da classe Name, como segue:

static validate (name: string): boolean {
    if (!name || name.trim().length < 2 || name.trim().length > 255) {
      return false
    }
    return true
  }

Atributos privados na classe *User*

Para manter a padronização com as demais classes (Name e Email) e aprimorar o encapsulamento, os atributos da classe User poderiam ser privados (private). Fiz um pull request apresentando a maneira como isso poderia ser implementado, mas você pode rejeitá-lo, se quiser. É só uma dica mesmo ;)

Dockerizar o projeto

O projeto poderia vir com um script docker-compose.yml que subiria um mongodb+mongo express (web ui para o mongo) e um servidor smtp simulado que rodaria local (caso a API necessite de um serviço de email), e claro, no up do docker-compose poderia rodar o projeto node / a API backend em si também (dai a pessoa consegue sem ter node instalado na máquina, dependeria apenas de ter o engine do docker mesmo).

Se nao puder fazer posso enviar um PR pra ti com essa melhoria ;-)

PS: Resolvi contribuir porque devo usar seu projeto como base para uns projetos meus, e sendo assim não vejo porque não contribuir de alguma forma para melhorá-lo nem que seja só um pouco.

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.