-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from loryblu/develop
sync: develop
- Loading branch information
Showing
52 changed files
with
10,062 additions
and
6,950 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
dist | ||
docs | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM node:18-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json . | ||
COPY src/modules/mail/templates/package.json . | ||
|
||
RUN yarn install --exact --ignore-scripts | ||
|
||
COPY . . | ||
|
||
EXPOSE 5500 | ||
|
||
CMD ["yarn", "dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,9 @@ | |
<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` | ||
|
@@ -25,63 +25,94 @@ git clone https://github.com/loryblu/loryblu-api.git loryblu-api | |
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 | ||
SECRET_JWT=[Senha para os tokens de acesso] | ||
|
||
MAIL_FROM=[Email de contato da aplicação] | ||
# ex: [email protected] | ||
# ex: example123# | ||
|
||
MAIL_PORT=[Porta de acesso do serviço de e-mail] | ||
|
||
# ex: 1234 | ||
|
||
MAIL_HOST=[Domínio do serviço de e-mail] | ||
|
||
# ex: smtp.email.com.br | ||
|
||
MAIL_USER=[Nome do usuário de e-mail] | ||
|
||
# ex: User123 | ||
|
||
MAIL_PASS=[Senha de acesso ao serviço de e-mail] | ||
|
||
# ex: abcde123456 | ||
|
||
MAIL_NAME=[Nome da API] | ||
|
||
# ex: LoryBlu | ||
|
||
MAIL_TEST_DELIVERED=[Email para teste : sucesso] | ||
# ex: [email protected] | ||
MAIL_FROM=[E-mail de contato da aplicação] | ||
|
||
MAIL_TEST_BOUNCED=[Email para teste : erro] | ||
# ex: [email protected] | ||
# ex: [email protected] | ||
|
||
MAIL_WHITELIST=[Lista de e-mails para teste] | ||
|
||
MAIL_TEST_COMPLAINED=[Email para teste : marcado como spam] | ||
# ex: [email protected] | ||
# ex: [email protected],[email protected],[email protected] | ||
|
||
POSTGRES_USER=[Nome de usuário do banco 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 | ||
$ git submodule update --init --recursive | ||
``` | ||
|
@@ -99,13 +130,11 @@ $ yarn | |
<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 | ||
``` | ||
Use o comando abaixo para executar a aplicação no docker e configurar as credenciais. | ||
|
||
Se preferir, há um script configurado para realizar este comando e todos os outros de desenvolvimento. Ele também inicia a aplicação: | ||
```bash | ||
# Baixar imagem ` postgres:11.19-alpine ` e configurar base de dados; | ||
# Baixar imagem ` node:18-alpine ` e configurar aplicação node; | ||
yarn docker:dev | ||
``` | ||
|
||
|
@@ -114,23 +143,27 @@ yarn docker:dev | |
--- | ||
|
||
Esse comando executa tudo o que é necessário para configurar o banco de dados de desenvolvimento. | ||
|
||
```bash | ||
$ yarn dev | ||
``` | ||
|
||
Esse comando apenas inicia a aplicação no modo de desenvolvimento. | ||
|
||
```bash | ||
$ yarn start:dev | ||
``` | ||
|
||
Esse comando inicia a aplicação no modo de produção. | ||
|
||
```bash | ||
$ yarn run start:prod | ||
``` | ||
|
||
## Testes | ||
|
||
Testes unitários | ||
|
||
```bash | ||
$ yarn test | ||
``` | ||
|
@@ -141,19 +174,19 @@ LoryBlu tem [licença MIT](LICENSE). | |
|
||
</details> | ||
|
||
|
||
Description in <b>en</b> | ||
|
||
### Requirements | ||
|
||
1. [Node.js 18.x LTS](https://nodejs.org/en) Installed. | ||
1. [PostgreSQL](https://www.postgresql.org/) or [docker + docker-compose](https://docs.docker.com/compose/) installed. | ||
1. [Resend](https://resend.com/home) Email service used in the application. | ||
|
||
> ⚠ If you have `docker` and `docker-compose` intalled, you do not need to install `PostgreSQL` (database), there is a configured file to use PostgreSQL in docker, `docker-compose.dev.yml` | ||
> ⚠ If you have `docker` and `docker-compose` intalled, you do not need to install `PostgreSQL` (database), there is a configured file to use PostgreSQL in docker, `docker-compose.dev.yml` | ||
## Clone the repository | ||
|
||
Unit tests | ||
|
||
```bash | ||
# git clone <repo-url> <dist> | ||
git clone https://github.com/loryblu/loryblu-api.git loryblu-api | ||
|
@@ -162,69 +195,102 @@ git clone https://github.com/loryblu/loryblu-api.git loryblu-api | |
This comamnd will clone the repository to the specified destination. You can omit the destination. | ||
|
||
## Set up the enviroment | ||
|
||
1. Duplicate the `.env.example` file from the main project; | ||
1. Rename it to `.env`; | ||
|
||
Update the new `.env` with the following instructions: | ||
|
||
```md | ||
# Replace the examples inside square brackets "[Database username]" with the final value "root" | ||
|
||
PORT=[Port that the server exposes] | ||
|
||
# e.g.: 8080 | ||
|
||
NODE_ENV=[Current environment] | ||
|
||
# e.g.: development | ||
|
||
SALT_DATA_HASH=[Secret key to merge with the sensitive data hash] | ||
|
||
# e.g.: secret.salt.data | ||
|
||
SALT_DATA_PASS=[Secret key to randomize the password] | ||
|
||
# e.g.: 8 | ||
|
||
MAIL_API_KEY=[Resend service key] | ||
# e.g.: re_123456789 | ||
SECRET_JWT=[Access token password] | ||
|
||
# e.g.: example123# | ||
|
||
MAIL_PORT=[Email service access port] | ||
|
||
# ex: 1234 | ||
|
||
MAIL_HOST=[Email service domainl] | ||
|
||
# ex: smtp.email.com.br | ||
|
||
MAIL_USER=[Email user name] | ||
|
||
# ex: User123 | ||
|
||
MAIL_PASS=[Email service access password] | ||
|
||
# ex: abcde123456 | ||
|
||
MAIL_NAME=[API name] | ||
|
||
# ex: LoryBlu | ||
|
||
MAIL_FROM=[Application contact email] | ||
# e.g.: [email protected] | ||
|
||
MAIL_TEST_DELIVERED=[Test email : success] | ||
# e.g.: [email protected] | ||
# ex: [email protected] | ||
|
||
MAIL_TEST_BOUNCED=[Test email : error] | ||
# e.g.: [email protected] | ||
MAIL_WHITELIST=[List of test emails] | ||
|
||
MAIL_TEST_COMPLAINED=[Test email: marked as spam] | ||
# e.g.: [email protected] | ||
# ex: [email protected],[email protected],[email protected] | ||
|
||
POSTGRES_USER=[Database username] | ||
|
||
# e.g.: admin | ||
|
||
POSTGRES_PASSWORD=[Database password] | ||
|
||
# e.g.: strongPass | ||
|
||
POSTGRES_DB=[Database name] | ||
|
||
# e.g.: loryblu-clone-api | ||
|
||
POSTGRES_HOST=[Database host] | ||
|
||
# e.g.: localhost | ||
|
||
POSTGRES_PORT=[Database port] | ||
|
||
# e.g.: 5432 | ||
|
||
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?schema=public" | ||
# ! This value does not need to be changed, use it as is. | ||
|
||
# ! This value does not need to be changed, use it as is. | ||
``` | ||
|
||
## Installation | ||
|
||
### Submodules | ||
|
||
After cloning this repository, and if one of the submodules is added or updated, run the following command to update and initialize all submodules. | ||
|
||
```bash | ||
$ git submodule update --init --recursive | ||
``` | ||
|
||
### Dependencies | ||
|
||
After cloning and whenever you update the repository, run the following command to keep the dependencies up to date. | ||
|
||
```bash | ||
$ yarn | ||
``` | ||
|
@@ -234,13 +300,11 @@ $ yarn | |
<details> | ||
<summary><b>Are you using Docker?</b></summary> | ||
|
||
Use the command below to download the PostgreSQL:14-alpine image and configure the credentials. | ||
```bash | ||
docker-compose -f docker-compose.dev.yml up -d | ||
``` | ||
Use the command below to run the application in Docker and configure the credentials | ||
|
||
If you prefer, there is a script configured to perform this command and all other development commands. It also starts the application: | ||
```bash | ||
# Download the ` postgres:11.19-alpine ` image and configure the database; | ||
# Download the ` node:18-alpine ` image and configure the Node application; | ||
yarn docker:dev | ||
``` | ||
|
||
|
@@ -249,23 +313,27 @@ yarn docker:dev | |
--- | ||
|
||
This command performs everything necessary to set up the development database. | ||
|
||
```bash | ||
$ yarn dev | ||
``` | ||
|
||
This command only starts the application in development mode. | ||
|
||
```bash | ||
$ yarn start:dev | ||
``` | ||
|
||
This command starts the application in production mode. | ||
|
||
```bash | ||
$ yarn run start:prod | ||
``` | ||
|
||
## Tests | ||
|
||
Unit tests | ||
|
||
```bash | ||
$ yarn test | ||
``` | ||
|
Oops, something went wrong.