Skip to content

Commit

Permalink
sync develop (#13)
Browse files Browse the repository at this point in the history
* build: setup deploy homologation

* chore: changes jest root dir

* test: creates services tests

* build: setup husky

* chore(deps): includes husky

* chore: uses pre-push event

* feat(submodule): includes mail-templates submodule

* chore: specify what JSX code is generated

* chore(deps): install @react-email/render and submodule dependencies

* chore(deps): install resend dependencies

* chore(dev-deps): install ` dotenv-cli ` and ` @types-react ` packages

* feat: creates mail service

* docs: updates swagger documentation and example files

* chore(onerror): shows error when trying to load html

* styles: variable destructuring

* chore(deps): install ` class-validator ` and ` class-transformer ` packages

chore(main): configure useGlobalPipes

* refactor: renames properties

* feat: creates new account method

* chore(dev-deps): install the faker-js package to generate test values

* test: creates simple tests for newAccountPropsProcessing method

* chore: changes container name

* chore: shows the port on which the server is running

* docs: updates description

* build(`ci-cd`): configure testing.yml for unit tests

* docs: updates api description

* chore(submodule): updates email-templates

* refactor: changes file name

* chore: updates mail loader

* chore: sync submodule

* chore: updates templates

* chore: updates validation messages

* chore: creates encryptData method

* refactor: updates prisma known errors

* chore: encrypt password and hash email

* docs: add new environment variable descrition

* chore: import bcrypt

* chore: updates create account expect

* chore: changes messages and examples

* feat: creates reset password information scheme

* chore: log known errors

* refactor: change log type

* chore: includes default error

* chore: removes prismaKnownValidationErrors

* chore: updates error messages

* feat: creates and saves token to reset password

* chore: await send mail

* feat: send link to reset password

* chore: changes description

* test: create reset password tests

* chore: changes setup

* chore: await save token

* styles: changes file name

* styles: rename folders

* feat: creates set password route

* feat: saves the new password and deletes the old recovery token

* refactor: changes the way errors are handled

* refactor: move files

* fix: sets 5 minutes to expires the token

* chore: update config (#12)

* chore(deps): includes helmet and nestjs/config dependencies

* chore(sec): configure cors and helmet

* refactor: remove unnecessary imports

* chore: updates date example

* fix(birthdate): fixes format validation

---------

Co-authored-by: Daiane Bolzan <[email protected]>
  • Loading branch information
viniciuscosmome and Daaaiii committed Sep 20, 2023
1 parent a7c4a40 commit d0cd007
Show file tree
Hide file tree
Showing 43 changed files with 3,186 additions and 538 deletions.
13 changes: 8 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
PORT=5500
NODE_ENV=development

EMAIL_HOST=[Email host name]
EMAIL_PORT=[Email port]
EMAIL_USERNAME=[Email user name]
EMAIL_PASSWORD=[Email password]
FROM_EMAIL=[Email adress]
SALT_DATA_HASH=[string]
SALT_DATA_PASS=[string]

MAIL_API_KEY=[string]
MAIL_FROM=[string]
MAIL_TEST_DELIVERED=[string]
MAIL_TEST_BOUNCED=[string]
MAIL_TEST_COMPLAINED=[string]

POSTGRES_USER=admin
POSTGRES_PASSWORD=admin
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Deploy homologation environment

on:
push:
branches:
- homologation

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Execute cURL
run: |
curl -X POST ${{ secrets.DEPLOY_HOMOLOGATION_URL }}
28 changes: 28 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run tests

on:
pull_request:
branches:
- develop
- homologation

jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.JS ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install packages
run: yarn

- name: Unit tests
run: yarn test
78 changes: 39 additions & 39 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
package-lock.json
.env
*.todo

# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
package-lock.json
.env
*.todo

# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/modules/mail/templates"]
path = src/modules/mail/templates
url = https://github.com/loryblu/email-templates.git
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
src/modules/mail/templates
141 changes: 123 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,140 @@
## Installation
# LoryBlu API

![version](https://img.shields.io/github/package-json/v/loryblu/loryblu-api?style=flat-square&labelColor=f2f2f2&color=white)
![license](https://img.shields.io/github/license/loryblu/loryblu-api?style=flat-square&labelColor=f2f2f2&color=white)
![main tool](https://img.shields.io/badge/Nest_JS-f2f2f2?logo=nestjs&logoColor=db1737&style=flat-square)
![Database](https://img.shields.io/badge/PostgreSQL-50b0f0?logo=postgresql&logoColor=f2f2f2&style=flat-square)

<details>
<summary>Descrição em <b>pt-BR</b></summary>

### Requisitos
1. [Node.js 18.x LTS](https://nodejs.org/en) Instalado.
1. [PostgreSQL](https://www.postgresql.org/) ou [docker + docker-compose](https://docs.docker.com/compose/) instalado.
1. [Resend](https://resend.com/home) Serviço de e-mail usado na aplicação.

> ⚠ Se você tem o `docker` e `docker-compose` instalados, não precisa instalar o `PostgreSQL` (banco de dados), há um arquivo configurado para usar o PostgreSQL no docker, o `docker-compose.dev.yml`
## Clone o repositório

```bash
$ yarn install
# git clone <repo-url> <dist>
git clone https://github.com/loryblu/loryblu-api.git loryblu-api
```

## Running the app
Este comando vai clonar o repositório para o destino definido. Você pode omitir o destino.

## Configurar ambiente
1. Duplique o arquivo `.env.example` do projeto principal;
1. Renomeie para `.env`;

Atualize o novo `.env` com as instruções a seguir:
```md
# Substitua os exemplos dentro dos colchetes "[Database username]" pelo valor final "root"

PORT=[Porta que o servidor expõe]
# ex: 8080

NODE_ENV=[Ambiente atual]
# ex: development

SALT_DATA_HASH=[Chave secreta para mesclar com o hash de dados sensíveis]
# ex: secret.salt.data

SALT_DATA_PASS=[Chave secreta para randomizar a senha]
# ex: 8

MAIL_API_KEY=[Chave do serviço Resend]
# ex: re_123456789

MAIL_FROM=[Email de contato da aplicação]
# ex: [email protected]

MAIL_TEST_DELIVERED=[Email para teste : sucesso]
# ex: [email protected]

MAIL_TEST_BOUNCED=[Email para teste : erro]
# ex: [email protected]

MAIL_TEST_COMPLAINED=[Email para teste : marcado como spam]
# ex: [email protected]

POSTGRES_USER=[Nome de usuário do baco de dados]
# ex: admin

POSTGRES_PASSWORD=[Senha do banco de dados]
# ex: strongPass

POSTGRES_DB=[Nome da base de dados]
# ex: loryblu-clone-api

POSTGRES_HOST=[Host do banco de dados]
# ex: localhost

POSTGRES_PORT=[Porta do banco de dados]
# ex: 5432

DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?schema=public"
# ! Este valor não precisa ser alterado, use-o como está.
```

## Instalação
### Submódulos
Depois de clonar este repositório, e se for adicionado ou atualizado um dos submódulos, execute o comando abaixo para atualizar e iniciar todos os submódulos.
```bash
# development
$ yarn run start
$ git submodule update --init --recursive
```

# watch mode
$ yarn run start:dev
### Dependências

# production mode
$ yarn run start:prod
Depois de clonar e semple que atualizar o repositório, execute o comando abaixo para manter as dependências atualizadas.
```bash
$ yarn
```

## Executando a aplicação

<details>
<summary><b>Está usando docker?</b></summary>

Use o comando abaixo para baixar a imagem do PostgreSQL:14-alpine e configurar as credenciais.
```bash
docker-compose -f docker-compose.dev.yml up -d
```

Se preferir, há um script configurado para realizar este comando e todos os outros de desenvolvimento. Ele também inicia a aplicação:
```bash
yarn docker:dev
```

## Test
</details>

---

Esse comando executa tudo o que é necessário para configurar o banco de dados de desenvolvimento.
```bash
# unit tests
$ yarn run test
$ yarn dev
```

# e2e tests
$ yarn run test:e2e
Esse comando apenas inicia a aplicação no modo de desenvolvimento.
```bash
$ yarn start:dev
```

# test coverage
$ yarn run test:cov
Esse comando inicia a aplicação no modo de produção.
```bash
$ yarn run start:prod
```

## License
## Testes

Testes unitários
```bash
$ yarn test
```

## Licença

LoryBlu tem [licença MIT](LICENSE).

Nest is [MIT licensed](LICENSE).
</details>
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'
services:
database:
image: postgres:14-alpine
container_name: postgres
container_name: loryblu-postgres
env_file:
- .env
volumes:
Expand Down
Loading

0 comments on commit d0cd007

Please sign in to comment.