Skip to content

Commit

Permalink
Merge pull request #69 from wendesongomes/main
Browse files Browse the repository at this point in the history
Arrumei alguns problemas que impedia o servidor ser rodado localmente
  • Loading branch information
thiagorcode authored May 21, 2024
2 parents ce4e547 + 8728ed4 commit 1e071dc
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 66 deletions.
12 changes: 10 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ PORT=
SECRET_KEY=

# DATABASE CONNECTION
DATABASE_URL=
DATABASE_URL=postgresql://docker:ignite@mentores-backend.soujunior.tech:5432/mentores_backend
DATABASE_URL_LOCAL=postgresql://docker:ignite@localhost:5432/mentores_backend
URL_CONFIRM_EMAIL=http://localhost:Porta que o frontend esta rodando/confirmacao
URL_RESTORATION_EMAIL=http://localhost:Porta que o frontend esta rodando/setNewPassword

#Para fazer a captura de email, use o https://mailtrap.io/, caso esteja na duvida como usar olhe o readme.

#EMAIL INFO
MAIL_HOST=
MAIL_PORT=
MAIL_USER=
MAIL_PASSWORD=
MAIL_PASSWORD=

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_S3_BUCKET_NAME=
103 changes: 51 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,72 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Installation
# mentores-backend

Projeto Opensource que visa melhorar o match entre Mentores e Juniors.

## Observação:

>Antes de iniciar a instalação, lembre-se de fazer um fork do repositório oficial e realizar as alterações no repositório "forkado" enviando modificações através de Pull Requests. Nunca modifique diretamente o repositório oficial.

Clone o projeto:

```bash
$ npm install
git clone https://github.com/{SEU USUARIO}/mentores-backend.git
```

## Running the app
Entre no diretório do projeto:

```bash
# development
$ npm run start
cd mentores-backend/
```

# watch mode
$ npm run start:dev
Instale as dependências:

# production mode
$ npm run start:prod
```bash
npm install
```

## Test
## Rodando localmente

- Verifique se esta com o docker instalado e aberto

Dentro da pasta mentores-backend, rode o seguinte comando:

```bash
# unit tests
$ npm run test
docker-compose up -d
```

com o banco de dados rodando localmente, só precisa pegar as variaveis .env com alguem do projeto.

# e2e tests
$ npm run test:e2e
## Como utilizar o mailtrap.

# test coverage
$ npm run test:cov
Entre no [Mailtrap](https://mailtrap.io) e crie uma conta, com a conta criada vá em email Testing e clique em my inbox:

![image](https://github.com/wendesongomes/mentores-backend/assets/82889172/f966d27c-6a13-4a7a-90c9-3b3a37500ae8)

Veja a parte de Integration e clique em Show Credentials, vai precisar do Host, Port, Username e Password.

![image](https://github.com/wendesongomes/mentores-backend/assets/82889172/efcbb466-69d9-4264-8553-4b73bfa13eb4)
![image](https://github.com/wendesongomes/mentores-backend/assets/82889172/c6b59518-f9a7-40d7-817e-d3c429e12fbe)

Agora só utilizar o:

```bash
npm run dev
```

## Support
### Mailtrap não capturou o email

Caso você tenha feito isso tudo e não recebeu o email no mailtrap faça o seguinte, Na pasta do mentores-backend vá em:

src/modules/mails/mail.module.ts

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
dentro dela tem um:

## Stay in touch
```bash
secure: true,
```

- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
![image](https://github.com/wendesongomes/mentores-backend/assets/82889172/0386598d-5053-4189-9e9b-e7d1a4ef1655)

## License

Nest is [MIT licensed](LICENSE).
troque para false, com isso o mailtrap vai capturar seus emails normalmente.
9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ services:
- POSTGRES_PASSWORD=ignite
- POSTGRES_DB=mentores_backend
volumes:
- pgdata:/data/postgres
- pgdata:/var/lib/postgresql/data

mentores_backend:
build: .
container_name: mentores_backend
Expand All @@ -21,15 +22,13 @@ services:
- 3000:3000
volumes:
- .:/usr/app
links:
- database_soujunior
depends_on:
- database_soujunior
env_file:
- .env
environment:
- DATABASE_URL=postgresql://docker:ignite@mentores_backend:3306/mentores_backend?reconnect=true
- DATABASE_URL=postgresql://docker:ignite@database_soujunior:5432/mentores_backend

volumes:
pgdata:
driver: local
driver: local
14 changes: 7 additions & 7 deletions src/modules/mails/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class MailService {

async mentorSendEmailConfirmation(mentor: MentorEntity): Promise<void> {
const { email, fullName, code } = mentor;
const url = `${process.env.URL_CONFIRM_EMAIL}code=${code}&email=${email}`;
const url = `${process.env.URL_CONFIRM_EMAIL}?code=${code}&email=${email}`;

await this.mailerService
.sendMail({
Expand All @@ -32,9 +32,9 @@ export class MailService {
const { email, fullName, code } = mentor;
const { URL_CONFIRM_EMAIL } = process.env;

const url = `${URL_CONFIRM_EMAIL}code=${code}&email=${email}`;
const url = `${URL_CONFIRM_EMAIL}?code=${code}&email=${email}`;

console.log( this.mailerService)
console.log(this.mailerService);
try {
await this.mailerService
.sendMail({
Expand All @@ -59,7 +59,7 @@ export class MailService {
const { email, code } = mentorData;
const { URL_RESTORATION_EMAIL } = process.env;

const url = `${URL_RESTORATION_EMAIL}code=${code}&email=${email}`;
const url = `${URL_RESTORATION_EMAIL}?code=${code}&email=${email}`;

try {
await this.mailerService
Expand All @@ -81,7 +81,7 @@ export class MailService {

async userSendEmailConfirmation(user: UserEntity): Promise<void> {
const { email, fullName, code } = user;
const url = `${process.env.URL_CONFIRM_EMAIL}code=${code}&email=${email}`;
const url = `${process.env.URL_CONFIRM_EMAIL}?code=${code}&email=${email}`;

await this.mailerService
.sendMail({
Expand All @@ -102,7 +102,7 @@ export class MailService {
const { email, fullName, code } = user;
const { URL_CONFIRM_EMAIL } = process.env;

const url = `${URL_CONFIRM_EMAIL}code=${code}&email=${email}`;
const url = `${URL_CONFIRM_EMAIL}?code=${code}&email=${email}`;

try {
await this.mailerService
Expand All @@ -128,7 +128,7 @@ export class MailService {
const { email, code } = userData;
const { URL_RESTORATION_EMAIL } = process.env;

const url = `${URL_RESTORATION_EMAIL}code=${code}&email=${email}`;
const url = `${URL_RESTORATION_EMAIL}?code=${code}&email=${email}`;

try {
await this.mailerService
Expand Down

0 comments on commit 1e071dc

Please sign in to comment.