Skip to content

Commit

Permalink
Versão 2.0.0 Mutt (#125)
Browse files Browse the repository at this point in the history
* Add backup scheduler to mongodb miaAjudaDB database.

* Add rclone file to .gitignore.

* Add docker-compose prod file to backup database.

* Update README.md with database backup instructions.

* Standart pages name to start with capital letter

* Change middleware to routes.use

* Finish helpOffer structure and fix route mess

* Create help offer methods and routes

Co-authored-by: Co-authored-by: Ivan Dobbin <[email protected]>

* Create addPossibleHelpedUsers in service and controller

Co-authored-by: gabrieldvpereira <[email protected]>
Co-authored-by: Ivan Dobbin <[email protected]>

* Created Entity model

* Created Entity routes

* Created Entity repository

* Created Entity controller

* Created Entity Service and update validation on User Service

* Add route addPossibleHelpedUsers

* Add email option to check user or entity existence.

* Delete unused route

* Change help request route name

* Fix eslint problems and improve code readability.

* Removing console.log

* Remove console logs and insert await in call of async functions

* Create function shortList

* Put authentication in getHelpList

* Initial find without agregation

* Change the model to recieve an array of category

* Add projection to show just wanted fields in agreggation

* Added first version of Campaign backend

* Added a new info to know track user type on firebase

* remove console.logs

* Create route to retrieve the rest of the informations of a help

* Gotten campaign with coords from back

* Created delete route and remove unused functions

* Create help category

* Fix error of finding helps of the own user

* Add rclone backup to gitlab CI/CD.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* 96 - Add aggregation in get help by id

* Fixed routes with same name

* Initial project

* Passing campaigns status to front and now entity can help user

* 96 - Add route to get help with aggregation of user data

* Create helpOffer agreggation

* lookup on categories

* add possible entities to help

* Fix error in socket and error with getHelpListByStatus

* Updated Back to delete campaigns

* Show only the needed information of a possibleHelper

* Fixed bug when choose an entity as helper

* Set the offerhelp list to not return user own offers

* Add sort by date offerhelp

* Added a new route to get any type of user

* Separate the fields that only myRequests or myOffer uses

* Now help offers of an entity are listed

* Remove return from createHelp

* Added a new file to ignore

* Delete miaajuda.pem

hsa private key cant be null

* fix bug that prevent the server to return user own help

* Help update routes do not return content.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Create logic to return user photo seperaly

* Remove function to get user photo

* Create function for aggregation of createHelp and shortList.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Revert "Remove function to get user photo"

This reverts commit 59f8123.

* Reverting Commit on develop

* Merge and fixed commits

* Fix problem to return possiblehelpoers for a help

Co-authored-by: DanilloGs <[email protected]>

* Fixing lint problems

* resolve conflicts

* 96 - Change aggregations fields

* Bump bcrypt from 4.0.1 to 5.0.0

Bumps [bcrypt](https://github.com/kelektiv/node.bcrypt.js) from 4.0.1 to 5.0.0.
- [Release notes](https://github.com/kelektiv/node.bcrypt.js/releases)
- [Changelog](https://github.com/kelektiv/node.bcrypt.js/blob/master/CHANGELOG.md)
- [Commits](kelektiv/node.bcrypt.js@v4.0.1...v5.0.0)

Signed-off-by: dependabot[bot] <[email protected]>

* Resolved conflicts

* Added logic to finish a campaign

* Fix the bug to return my own helpoffer

* Update HelpOfferController.js

Remove console.log

* Remove getHelpId from route and controller as it is not being used in front-end

* Change getHelpListByStatus to retrieve possibleEntities and getByIdWithAggregation to retrieve a help

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Filter Offers

Co-authored-by: Duda Melo <[email protected]>

* Add project to getByIdWithAggregation.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Bump bl from 2.2.0 to 2.2.1

Bumps [bl](https://github.com/rvagg/bl) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/rvagg/bl/releases)
- [Commits](rvagg/bl@v2.2.0...v2.2.1)

Signed-off-by: dependabot[bot] <[email protected]>

* Bump node-fetch from 2.6.0 to 2.6.1

Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](node-fetch/node-fetch@v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <[email protected]>

* create route to send notifications to all users

* Create route for deleting a helpOffer.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Add authorization before deleting an OfferHelp.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Fixed route to get only help offers from owner

* #44 - Fixed route to return help offers

Co-authored-by: Dâmaso Júnio <[email protected]>

* #44 - List of help offers is done

Co-authored-by: Damaso Junio <[email protected]>

* Rota para pegar uma Campanha Individual

Co-authored-by: Joao Pedro <[email protected]>

* Bump socket.io from 2.3.0 to 2.4.0

Bumps [socket.io](https://github.com/socketio/socket.io) from 2.3.0 to 2.4.0.
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/2.4.0/CHANGELOG.md)
- [Commits](socketio/socket.io@2.3.0...2.4.0)

Signed-off-by: dependabot[bot] <[email protected]>

* Add notification to route /helpOffer/possibleHelpedUsers.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Insert validation to /helpOffer/possibleHelpedUsers/ to check if user is already on possibleHelpedUsers.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Create function that checks if user is entity or not.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Create global variable that informs if user is entity or not.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Create function that finds one entity with provided projection.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Send notification to Offer owner when another user requests help.

Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Welison Almeida <[email protected]>

* Fix error message

* US57 - Agora a ONG pode finalizar uma campanha quando for necessario

* Update CampaignRoutes.js

* Update CampaignRoutes.js

* Bump lodash from 4.17.19 to 4.17.21

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <[email protected]>

* Bump hosted-git-info from 2.8.8 to 2.8.9

Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](npm/hosted-git-info@v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <[email protected]>

* User can't help his own offer

* Bump ws from 7.4.2 to 7.4.6

Bumps [ws](https://github.com/websockets/ws) from 7.4.2 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@7.4.2...7.4.6)

Signed-off-by: dependabot[bot] <[email protected]>

* Fix retrieve of offers in map and in MINHAS OFERTAS

* Bump glob-parent from 5.1.1 to 5.1.2

Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.1 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](gulpjs/glob-parent@v5.1.1...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump normalize-url from 4.5.0 to 4.5.1

Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)

---
updated-dependencies:
- dependency-name: normalize-url
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* add route to get helpOffer aggregation by id

Co-authored-by: Brian Pina de Sá <[email protected]>
Co-authored-by: Ivan Dobbin <[email protected]>

* Fix error when setting userType

* Bump socket.io-parser from 3.3.0 to 3.3.2

Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 3.3.0 to 3.3.2.
- [Release notes](https://github.com/socketio/socket.io-parser/releases)
- [Changelog](https://github.com/socketio/socket.io-parser/blob/3.3.2/CHANGELOG.md)
- [Commits](socketio/socket.io-parser@3.3.0...3.3.2)

---
updated-dependencies:
- dependency-name: socket.io-parser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Refactor aggregations to remove duplication

* Solve - Updating Contributing Guide (#109)

* docs: add contributing guide

* style: add commit lint

* docs: fix documents

* feat: Adding the correct aggregation return from helpOfferRepository (#110)

Co-authored-by: Thiago Paiva <[email protected]>

* fix: populating help with possibleHelpers

Co-authored-by: Rafael Cleydson <[email protected]>

* Bump tar from 4.4.13 to 4.4.15 (#113)

Bumps [tar](https://github.com/npm/node-tar) from 4.4.13 to 4.4.15.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v4.4.13...v4.4.15)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump path-parse from 1.0.6 to 1.0.7 (#115)

Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 174-refactoring aggregations (#112)

* refactor: getHelpInfoById aggregation

Also update Help's categoryId Field to be an array

Co-authored-by: Thiago Paiva <[email protected]>
Co-authored-by: Ivan Dobbin <[email protected]>

* Refactor: change create function in help repository and create function populateExistingDoc in Base repository

Co-authored-by: Lucas Amoêdo <[email protected]>
Co-authored-by: Thiago Paiva <[email protected]>

* Refactor: changing getEmailBYHelpOfferId's query to populate

* Refactor: adding categories virtual field

* Refactor: Refactoring getByIdWithAggregation to populate

* Refactor: refactoring list method to populate

* Refactor: adding sort methods

* Refactor: renaming category virtual field to categories

* Refactor: refactoring getCampaignListByStatus to populate

* Refactor: adding distances virtual fields

* Refactor: refactoring listNear to populate

* Refactor: renaming category virtual field to categories

* Refactor: refactoring getByIdWithAggregation to populate

* Refactor: adding distances virtual fields

* Refactor: refactoring listNear method to populate
The toObject method was necessary because without it the array was not updating

* Refactor: getHelpListByStatus aggregation in Help

Only part of it was refactored so far. The condition when we inform a
helper ID is not working yet.

* Refactor: getHelpListByStatus aggregation in Help

The condition when a helper is sent is now handled.

* Refactor: add missing categories to help

Co-authored-by: Lucas Amoêdo <[email protected]>
Co-authored-by: Thiago Paiva <[email protected]>

* US45 - Aceitação de pessoas interessadas para ajudar (#116)

* feat: Choosing helped user from interesteds on help offer

Co-authored-by: Damaso Junio <[email protected]>

* Changing chooseHelpedUser route name

* feat: changing from aggregations to populate method

Co-authored-by: Thiago Paiva <[email protected]>
Co-authored-by: Lucas Amoêdo <[email protected]>

* fix: adding isAuthenticated to access helpOffer routes

* feat: abstracting addHelped and addPossibleHelped methods on helpOfferService

* fix: adding helpOffer/helpedId params at isUserInPossibleHelpedUsers method

* fix: Modifying  virtual helpedUser ref and helpOfferFields on list func

* fix: Adding the corect param to possibleHelpedUser notification

Co-authored-by: Damaso Junio <[email protected]>
Co-authored-by: Thiago Paiva <[email protected]>
Co-authored-by: Lucas Amoêdo <[email protected]>

* US43: Deletando Oferta de Ajuda e Notificando pelo Socket (#114)

* Feat: sending deleted helpOffer to socket

Co-authored-by: Rodrigo Balbino <[email protected]>

* Fix: refactoring finish help offer

Co-authored-by: thiagohdaqw <[email protected]>

* Bump tar from 4.4.15 to 4.4.19 (#119)

Bumps [tar](https://github.com/npm/node-tar) from 4.4.15 to 4.4.19.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v4.4.15...v4.4.19)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump ajv from 6.12.2 to 6.12.6 (#121)

Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.12.2 to 6.12.6.
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](ajv-validator/ajv@v6.12.2...v6.12.6)

---
updated-dependencies:
- dependency-name: ajv
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump minimist from 1.2.5 to 1.2.6 (#122)

Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump node-fetch from 2.6.1 to 2.6.7 (#124)

Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](node-fetch/node-fetch@v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Hotfix - Filtro de ajuda/oferta da Instituição já candidatada (#118)

* Feat: filtering the help and offer already applied

* Fix: passing isUserEntity as params

* Bump protobufjs from 6.9.0 to 6.11.3 (#123)

Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 6.9.0 to 6.11.3.
- [Release notes](https://github.com/protobufjs/protobuf.js/releases)
- [Changelog](https://github.com/protobufjs/protobuf.js/blob/v6.11.3/CHANGELOG.md)
- [Commits](protobufjs/protobuf.js@v6.9.0...v6.11.3)

---
updated-dependencies:
- dependency-name: protobufjs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* update readme

Co-authored-by: Welison Almeida <[email protected]>
Co-authored-by: Gabriel Davi <[email protected]>
Co-authored-by: Co-authored-by: Ivan Dobbin <[email protected]>
Co-authored-by: Danillo Souza <[email protected]>
Co-authored-by: Ivan Diniz Dobbin <[email protected]>
Co-authored-by: Pedro Féo <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: saleh <[email protected]>
Co-authored-by: Duda Melo <[email protected]>
Co-authored-by: Dâmaso Júnio <[email protected]>
Co-authored-by: Rafael Ramos <[email protected]>
Co-authored-by: Brian Pina de Sá <[email protected]>
Co-authored-by: Saleh Kader <[email protected]>
Co-authored-by: Thiago Paiva <[email protected]>
Co-authored-by: Thiago Paiva <[email protected]>
Co-authored-by: Rafael Cleydson <[email protected]>
Co-authored-by: Lucas Amoêdo <[email protected]>
Co-authored-by: Rodrigo Balbino <[email protected]>
  • Loading branch information
19 people authored Jul 7, 2022
1 parent 17e93db commit 2d21abc
Show file tree
Hide file tree
Showing 44 changed files with 2,578 additions and 689 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,8 @@ dist

# package-lock (main is yarn.lock)
package-lock.json

# Arquivo de configuração de backup remoto
rclone.conf

miaajuda.pem
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ build:
IMAGE_NAME: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
before_script:
- cat $FIREBASE_CONFIG > ./src/config/firebaseAuthConfig.js
- cat $RCLONE_CONFIG > ./config/rclone.conf
script:
- echo "Building image"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
Expand All @@ -40,6 +41,7 @@ build stable:
IMAGE_NAME: "$CI_REGISTRY_IMAGE:stable"
before_script:
- cat $FIREBASE_CONFIG > ./src/config/firebaseAuthConfig.js
- cat $RCLONE_CONFIG > ./config/rclone.conf
script:
- echo "Building image"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
Expand Down
101 changes: 101 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Guia de Contribuição :smile:

Bem vindo ao Mia Ajuda!

Adoramos quando novas pessoas contribuem com o projeto. Queremos que a sua contribuição para o Mia Ajuda se torne a mais simples possível. Todas as ajudas ao projeto são bem vindas, seja:

* Reportando _bugs_ encontrados;
* Enviando correção de _bugs_;
* Propondo novas soluções para o projeto, seja: Visual, Arquitetural ou de Negócio;
* Propondo novas funcionalidades;
* Implementado novas funcionalidades previstas em _issues_ nos nossos repositórios.

Caso queira conhecer melhor nosso projeto, acesse o nosso [site](https://miaajuda.netlify.app/), nosso [Instagram](https://www.instagram.com/miaajuda/) ou a nossa [Organização no Github](https://github.com/mia-ajuda).

Para entrar em contato conosco, além de abrir uma _issue_ aqui no Github, você pode nos enviar um email, para: [email protected]

## Como Iniciar a sua Contribuição ao Mia Ajuda

Muito Obrigado pelo interesse em contribuir para o Projeto.

Para iniciar a sua jornada, você pode estar contribuindo para o projeto abrindo _issues_ em nosso repositório de documentação [repositório](https://github.com/mia-ajuda/Documentation/issues), seguindo o nosso [template](https://github.com/mia-ajuda/Documentation/tree/master/.github/ISSUE_TEMPLATE). Essas _issues_ podem ser abertas reportando possíveis _bugs_ ou sugerindo novas funcionalidades para o projeto.

Caso você queira contribuir para o código do Mia Ajuda, basta seguir os próximos passos:

* Busque a _issue_ na qual você se identifica, se marque e comente nessa _issue_. Atenção: Certifique-se antes, de que a _issue_ não está sendo resolvida por alguém, antes;
* Faça um _fork_ dos nossos repositórios, se você for um contribuidor externo;
* Crie uma _branch_ a partir da develop, seguindo nossas políticas de _branch_ abaixo;
* Crie um _Pull Request_ com o status _WIP_, no repositório para nos certificarmos que você está trabalhando na sua _issue_;
* Ao gerar _commits_, siga a nossa política de _commits_;
* Ao concluir o desenvolvimento da _issue_, troque o status do seu _Pull Request_ de _WIP_ para _Solve_, seguindo o nosso [template de Pull Request](https://github.com/mia-ajuda/Backend/blob/develop/.github/pull_request_template.md);
* Após um revisor aprovar o seu _Pull Request_, mescle-o com a a _branch_ base, seguindo a política do [_Squash Rebase_](https://docs.github.com/pt/github/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-pull-request-commits);

## _Workflow_ de Trabalho

Todo o nosso _workflow_ de trabalho é inteiramente baseado no [_GitFlow_](https://www.atlassian.com/br/git/tutorials/comparing-workflows/gitflow-workflow).

## Politicas de _Branches_

As _branches_ são dividas em camadas de desenvolvimento, baseado do modelo do [_GitFlow_](https://www.atlassian.com/br/git/tutorials/comparing-workflows/gitflow-workflow), sendo a `main` a camada que contém a aplicação em sua versão estável, a `develop` a versão de estado em desenvolvimento. Para a criação de `feature` _branches_ utilize a `develop` como base.

O formato para os nomes das _feature_ _branches_ será composto por:

US + NUMERO_DA_US + FUNCIONALIDADE.

Exemplo:
```
US13-Creation_of_a_new_screen
```

Para _hotfix branches_, o formato do nome da _branch_ se dará pela seguinte forma:

HOTFIX + NOME_DA_FIX

Exemplo:
```
hotfix_login_bug
```

### Mantendo as _branches_ atualizadas

Mantenha as suas _branches_ atualizadas com a _branch_ base. Utilize o comando _rebase_ para isso.

Exemplo:

```
> git pull --rebase origin develop
```

## Política de _Commits_

Os nossos _commits_ possuem um [_lint_](https://github.com/legend80s/commit-msg-linter#readme), sendo obrigatório seguir esse padrão:

```
tipo do commit: descrição concisa e em inglês do commit
```

Exemplo:

```
git commit -m "feat: create login button"
```

As nossas regras são:

* _Commits_ devem ser redigidos em idioma inglês;
* Devem seguir as regras do [_lint_](https://github.com/legend80s/commit-msg-linter#readme);
* Devem ser simples e concisos, possuindo títulos curtos;
* Devem iniciar com verbo no infinitivo informando o objetivo.

### _Commits_ em equipes

Caso mais de uma pessoa tenha trabalhado com você no _commit_, utilize do _Co-authored-by_, na descrição do _commit_.

Exemplo:

```
fix: fix contacts modal
Co-authored-by: Link <[email protected]>
```
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
</p>

<p align="center">
<a href="https://play.google.com/store/apps/details?id=com.unb.miaajuda" target="_blank"><img src="https://img.shields.io/badge/Mia%20Ajuda-Google%20Play-yellow"></a>
<a href="https://miaajuda.netlify.app/" target="_blank"><img src="https://img.shields.io/badge/Mia%20Ajuda-Website-blue"></a>
<a href="https://mia-ajuda.github.io/Documentation/#/" target="_blank"><img src="https://img.shields.io/badge/Mia%20Ajuda-Docs-purple"></a>
<a href="https://github.com/mia-ajuda/Backend/pulls" target="_blank"><img src="https://img.shields.io/github/issues-pr/mia-ajuda/Backend?color=red&label=Pull%20Requests"></a>
<a href="https://play.google.com/store/apps/details?id=com.unb.miaajuda" target="_blank" alt="Mia Ajuda na Google Play"><img src="https://img.shields.io/badge/Mia%20Ajuda-Google%20Play-yellow"></a>
<a href="https://miaajuda.netlify.app/" target="_blank" alt="Mia Ajuda Website"><img src="https://img.shields.io/badge/Mia%20Ajuda-Website-blue"></a>
<a href="https://mia-ajuda.github.io/Documentation/#/" target="_blank" alt="Mia Ajuda Documentação"><img src="https://img.shields.io/badge/Mia%20Ajuda-Docs-purple"></a>
<a href="https://github.com/mia-ajuda/Backend/pulls" target="_blank" alt="Mia Ajuda Pull Requests"><img src="https://img.shields.io/github/issues-pr/mia-ajuda/Backend?color=red&label=Pull%20Requests"></a>
</p>

## Rode o Backend com Docker


### Dependências

Inicialmente, instale localmente as seguintes dependências:
Expand Down Expand Up @@ -52,9 +53,13 @@ LONGITUDE_ENV=
SENTRY_DSN=
NODE_ENV=development
DATABASE_URL=mongodb://mongo/miaAjudaDB
MONGODB_USERNAME=
MONGODB_PASSWORD=
```

* O preenchimento do serviço de monitoramento de erros ([Sentry](https://sentry.io/)) é opcional. A latitude e a longitude serão utilizadas para popular exemplos de pedido de ajuda próximos a essa coordenada.
* O preenchimento do serviço de monitoramento de erros ([Sentry](https://sentry.io/)) é opcional.
* A latitude e a longitude serão utilizadas para popular exemplos de pedido de ajuda próximos a essa coordenada.
* As variáveis de ambiente `MONGODB_USERNAME` e `MONGODB_PASSWORD` destinam-se ao acesso da base de dados com autenticação. Ver detalhes de configuração de backup abaixo.

### Inicialização do Projeto

Expand All @@ -72,3 +77,25 @@ sudo docker-compose -f docker-compose.yml up --build
2. Na raiz do projeto, verifique a corretude do código com `eslint . --ext .js`; ou
3. Configure uma extensão no seu editor de texto preferido (exemplo: [VSCode - ESLINT](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint));
4. Abra o seu editor de texto na raiz do projeto `/Backend` e comece a desenvolver.

### Backup da Base de Dados

A aplicação realiza backups da base "miaAjudaDB" regularmente às 04h da manhã. O serviço guarda um total de 14 backups locais e sempre salva o backup no Google Drive. Para isso ser possível, proceda com as instruções:

#### Configuração do Backup

1. Preencha adequadamente as variáveis de ambiente do tópico "Arquivos de Configuração";
2. Salve na pasta `/Backend/config/` o arquivo `rclone.conf`;
3. Em produção, inicie os serviços de backend, banco e backup com:

```sh
sudo docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
```

#### Restauração do Backup

1. Para realizar a restauração de um backup, proceda com o comando:

```sh
mongorestore --gzip --archive=backup-scheduler-1594607580.gz --drop
```
24 changes: 24 additions & 0 deletions config/backup-scheduler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
scheduler:
# run every day at 4:00 UTC-3
cron: "0 7 */1 * *"
# number of backups to keep locally
retention: 14
# backup operation timeout in minutes
timeout: 60
target:
# mongod IP or host name
host: "mongo"
# mongodb port
port: 27017
# mongodb database name, leave blank to backup all databases
database: "miaAjudaDB"
# leave blank if auth is not enabled
username: ${MONGODB_USERNAME}
password: ${MONGODB_PASSWORD}
# add custom params to mongodump (eg. Auth or SSL support), leave blank if not needed
params: "--authenticationDatabase admin" # "--ssl"
rclone:
bucket: "MiaAjuda-Rclone"
# See https://rclone.org/docs/ for details on how to configure rclone
configFilePath: /config/rclone.conf
configSection: "MiaAjuda-Rclone"
16 changes: 16 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3"
services:
mgob:
container_name: mgob
environment:
- MONGODB_USERNAME=${MONGODB_USERNAME}
- MONGODB_PASSWORD=${MONGODB_PASSWORD}
image: stefanprodan/mgob:edge
command: ./mgob -LogLevel=info
volumes:
- ./config:/config
- /mgob/storage:/storage
- /mgob/tmp:/tmp
- /mgob/data:/data
depends_on:
- mongo
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@sentry/node": "5.18.0",
"bcrypt": "^4.0.1",
"bcrypt": "^5.0.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"cpf-cnpj-validator": "^1.0.1",
Expand All @@ -20,18 +20,19 @@
"express": "^4.17.1",
"faker": "^4.1.0",
"firebase-admin": "^8.10.0",
"lodash": "^4.17.19",
"lodash": "^4.17.21",
"mongodb": "^3.5.9",
"mongoose": "^5.9.6",
"node-schedule": "^1.3.2",
"socket.io": "^2.3.0",
"socket.io": "^2.4.0",
"swagger-ui-express": "^4.1.4",
"yamljs": "^0.3.0"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2",
"git-commit-msg-linter": "^3.2.6",
"nodemon": "^2.0.2"
}
}
9 changes: 3 additions & 6 deletions src/config/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ const envType = process.env.NODE_ENV || 'development';

const databaseConnect = async () => {
try {
await mongoose.connect(databaseURL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('Banco de dados conectado!'))
.catch((err) => {
console.log('Não foi possível se conectar ao banco de dados!');
console.log(err);
});
await mongoose.connect(databaseURL, { useNewUrlParser: true, useUnifiedTopology: true });
console.log('Banco de dados conectado!');
mongoose.set('useFindAndModify', false);

await CategorySeed();
// só popula usuários e ajudas falsos em desenvolvimento
Expand Down
Loading

0 comments on commit 2d21abc

Please sign in to comment.