From 1a5091a9e56ec4d5eead446bc54e57c61b0b72ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2020 02:50:32 +0000 Subject: [PATCH 01/28] Bump websocket-extensions from 0.1.3 to 0.1.4 Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-node) from 0.1.3 to 0.1.4. - [Release notes](https://github.com/faye/websocket-extensions-node/releases) - [Changelog](https://github.com/faye/websocket-extensions-node/blob/master/CHANGELOG.md) - [Commits](https://github.com/faye/websocket-extensions-node/compare/0.1.3...0.1.4) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index dca4d2d9..3308e561 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3848,9 +3848,9 @@ websocket-driver@>=0.5.1: websocket-extensions ">=0.1.1" websocket-extensions@>=0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29" - integrity sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg== + version "0.1.4" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" + integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== which-boxed-primitive@^1.0.1: version "1.0.1" From 63201870fb890bbe1db7e3ee3fe84c2f56db00e6 Mon Sep 17 00:00:00 2001 From: Gabriel Davi Date: Thu, 18 Jun 2020 17:58:32 -0300 Subject: [PATCH 02/28] Change firebase according to NODE_ENV --- docker-compose.yml | 1 + index.js | 22 +++++++++++----------- src/config/authFirebase.js | 16 ++++++++++++---- src/config/firebaseConfig-dev.js | 21 +++++++++++++++++++++ 4 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 src/config/firebaseConfig-dev.js diff --git a/docker-compose.yml b/docker-compose.yml index db27e245..b22e8642 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: container_name: backend environment: - DATABASE_URL=mongodb://mongo/miaAjudaDB + - NODE_ENV=development build: context: . dockerfile: Dockerfile diff --git a/index.js b/index.js index 3242bae0..9a492141 100644 --- a/index.js +++ b/index.js @@ -1,21 +1,21 @@ -require("dotenv").config(); +require('dotenv').config(); -const bodyParser = require("body-parser"); -const cors = require("cors"); -const express = require("express"); -const http = require("http"); -const setRoutes = require("./src/routes/BaseRoutes"); -const dailySchedule = require("./src/utils/schedule"); -const { setupWebsocket } = require("./websocket"); +const bodyParser = require('body-parser'); +const cors = require('cors'); +const express = require('express'); +const http = require('http'); +const setRoutes = require('./src/routes/BaseRoutes'); +const dailySchedule = require('./src/utils/schedule'); +const { setupWebsocket } = require('./websocket'); const app = express(); const server = http.Server(app); -app.use(express.json({ limit: "50mb" })); -app.use(express.urlencoded({ limit: "50mb" })); +app.use(express.json({ limit: '50mb' })); +app.use(express.urlencoded({ limit: '50mb' })); setupWebsocket(server); -const databaseConnect = require("./src/config/database"); +const databaseConnect = require('./src/config/database'); app.use(cors()); app.use(bodyParser.json()); diff --git a/src/config/authFirebase.js b/src/config/authFirebase.js index e10af93d..26b17e0b 100644 --- a/src/config/authFirebase.js +++ b/src/config/authFirebase.js @@ -1,11 +1,19 @@ +const admin = require('firebase-admin'); -const admin = require("firebase-admin"); +let firebaseConfig; +const enviroment = process.env.NODE_ENV; -const { config, databaseURL } = require("./firebaseConfig"); +if (enviroment === 'development') { + firebaseConfig = require('./firebaseConfig-dev'); +} else { + firebaseConfig = require('./firebaseConfig'); +} + +const { databaseURL, config } = firebaseConfig; admin.initializeApp({ - credential: admin.credential.cert(config), - databaseURL: databaseURL + credential: admin.credential.cert(config), + databaseURL, }); module.exports = admin; diff --git a/src/config/firebaseConfig-dev.js b/src/config/firebaseConfig-dev.js new file mode 100644 index 00000000..0371210f --- /dev/null +++ b/src/config/firebaseConfig-dev.js @@ -0,0 +1,21 @@ +const config = { + type: "service_account", + project_id: "miaajudadev", + private_key_id: "727c891bc781d80d79bdf7f48cf66ebaf3b7253f", + private_key: + "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDPC+VzHSVMs0WG\nKqeDprw0gYwHXBRKSxge0hK6oz9MdeR5zATX7/vW5547FMQs3G4h9MhH4GYQv1G/\nhFH79wETKsyQlSWvJPfsiErr8MXl3/EdDFJAeYh49tJwqnckTD8fo7K8BlUeVv0X\nq60/xEGBwk7z75o4YLCwx5MZ2yYebPnlZxyB6NmTKkFHaDsWb5+hsGymyaIGKtEi\n5MDG2LGj2sMtWOKhKEgfMqAHSuFsjL4t4khBt92o+ro4rlVGYrqfRGWk+EtAhQDx\nAiT/9/pulmdh8WneM7dq5ViuZRLO5j+nN/eelaEDVbY4bDO147tKohlh66XcGXWM\n0hQxfeebAgMBAAECggEAWlO+0Pc8sBcf9DYEqedigWepHwbZZUYYqk2M1TbmJSXj\nvQ04abqtfKbEvdLD+Sxbsd24SL9J1/GXqP2BxPKQWfvYjhU7gQsYTG1zfjanJ7AI\n4VrgQXekBd3sljGQU9odyeBhWC1NEjTyKtL/fOvShlkul7aG6iSowR74epXErg2k\nm2ZnVFby5eDJes0Nw1KoZkJ8rVpk1AUyeIaqc+GSLuRbEOAavX/1P2O4cCXJOno2\nbP7yCt4qRorKLq+RNTXPIqDStFTTiumGAw6n+oomQ87DrePctN5ORkDWr/QMzKBS\nSTUi0KM2zzs10x7jCKd/iiQ44wORVpLbP10D1LZ+oQKBgQD3YyDkfGtxuzoj/APf\nterlhWOTfSf/i9+fyjQVuAto9Tdmd7mPE8cwvCwzttmGkyIWWJPrLuyigGCrC8zv\nPjUtdRBEtXTLhyPeKNmgItO8VZWnPRpzJ8CnsXXdwVn44/CpHvG2UFXDXNioJ2g1\n0BAhi+L8c7kTTiYB/QTX9z0T+wKBgQDWQTm58lFGcFLu7nBT1apAACaW84zjJrAv\nq4vor4+h8ASM8gynlPc74Qfrf5Yn3nVFZhRtoWgd4MwDtdayArmX4zJUmN0mKZrK\nG6sDt97gHY0YebBtFCQWotb7KtXUMZXJ4IpyRD5SYDldSTK/JljCJuXx61Caw4c6\nweZbjfaI4QKBgQCMr40HI1KfDRCVYj55vKTm/iKQv749b7gu0Pkp2M50U++7kB6w\npVjD+F9S0YuHIqlh9+G2/6qHB2byHvXeoIvxW/9yc5cGH8ZgEu8gSG4NTsaaov8l\nudewBhW3lLur9UTpiLWBLtJ3FZgImNCEudxSl5DwbIc12V14CAH3J51OfQKBgQCs\nHH1o2DVd5kFY2oW1csBu5TAats8Icj26LY4Yf19ccNjW+GIeBNaObXjVPwq6QEPo\nWdYzMyPWTIzWti4flXzNfJ8jwiB01ZsYnB1GwV/ynQqJDMgi97j9zhXwcjqPWL3B\nC/VrUVLXDaFHRNPVJdLLNEAnlCaODGAHXVfVWDchQQKBgQDfObebo2KPP8aVokC5\n5NnzPrpzWNfl7asR7sf/HozpKDpT1NEoFptQo4zCe3dB6IyFvyQpJ+rgpyMrp/ut\nIRKXtzEz+LlRLLuIXIUyNbuK2o9ADHFvjQ88IVJ+Gg1PnSDUiVyr2X8hD/gbkU1W\n5kJQaH3Oru6GGQ8lhbvk2qo/fQ==\n-----END PRIVATE KEY-----\n", + client_email: "firebase-adminsdk-1djmt@miaajudadev.iam.gserviceaccount.com", + client_id: "105126767310578944074", + auth_uri: "https://accounts.google.com/o/oauth2/auth", + token_uri: "https://oauth2.googleapis.com/token", + auth_provider_x509_cert_url: "https://www.googleapis.com/oauth2/v1/certs", + client_x509_cert_url: + "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-1djmt%40miaajudadev.iam.gserviceaccount.com", +}; + +const databaseURL = "https://miaajudadev.firebaseio.com"; + +module.exports = { + config, + databaseURL, +}; From e369a0124fb6c6aa879aaf00a3b5f8ebcd240ba0 Mon Sep 17 00:00:00 2001 From: Gabriel Davi Date: Thu, 18 Jun 2020 22:45:18 -0300 Subject: [PATCH 03/28] config firebase to watch for node_env Co-authored-by: Pedro Feo --- .gitignore | 1 + docker-compose.yml | 1 - index.js | 1 - src/config/authFirebase.js | 7 +++---- src/config/firebaseConfig-dev.js | 21 --------------------- 5 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 src/config/firebaseConfig-dev.js diff --git a/.gitignore b/.gitignore index 324cdaa8..c85afcaf 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ jspm_packages/ # Firebase config src/config/firebaseConfig.js +src/config/firebaseConfig-dev.js # Snowpack dependency directory (https://snowpack.dev/) web_modules/ diff --git a/docker-compose.yml b/docker-compose.yml index b22e8642..db27e245 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,6 @@ services: container_name: backend environment: - DATABASE_URL=mongodb://mongo/miaAjudaDB - - NODE_ENV=development build: context: . dockerfile: Dockerfile diff --git a/index.js b/index.js index 9a492141..ce755737 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,6 @@ const server = http.Server(app); app.use(express.json({ limit: '50mb' })); app.use(express.urlencoded({ limit: '50mb' })); setupWebsocket(server); - const databaseConnect = require('./src/config/database'); app.use(cors()); diff --git a/src/config/authFirebase.js b/src/config/authFirebase.js index 26b17e0b..a712e1ee 100644 --- a/src/config/authFirebase.js +++ b/src/config/authFirebase.js @@ -2,11 +2,10 @@ const admin = require('firebase-admin'); let firebaseConfig; const enviroment = process.env.NODE_ENV; - -if (enviroment === 'development') { - firebaseConfig = require('./firebaseConfig-dev'); -} else { +if (enviroment === 'production') { firebaseConfig = require('./firebaseConfig'); +} else { + firebaseConfig = require('./firebaseConfig-dev'); } const { databaseURL, config } = firebaseConfig; diff --git a/src/config/firebaseConfig-dev.js b/src/config/firebaseConfig-dev.js deleted file mode 100644 index 0371210f..00000000 --- a/src/config/firebaseConfig-dev.js +++ /dev/null @@ -1,21 +0,0 @@ -const config = { - type: "service_account", - project_id: "miaajudadev", - private_key_id: "727c891bc781d80d79bdf7f48cf66ebaf3b7253f", - private_key: - "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDPC+VzHSVMs0WG\nKqeDprw0gYwHXBRKSxge0hK6oz9MdeR5zATX7/vW5547FMQs3G4h9MhH4GYQv1G/\nhFH79wETKsyQlSWvJPfsiErr8MXl3/EdDFJAeYh49tJwqnckTD8fo7K8BlUeVv0X\nq60/xEGBwk7z75o4YLCwx5MZ2yYebPnlZxyB6NmTKkFHaDsWb5+hsGymyaIGKtEi\n5MDG2LGj2sMtWOKhKEgfMqAHSuFsjL4t4khBt92o+ro4rlVGYrqfRGWk+EtAhQDx\nAiT/9/pulmdh8WneM7dq5ViuZRLO5j+nN/eelaEDVbY4bDO147tKohlh66XcGXWM\n0hQxfeebAgMBAAECggEAWlO+0Pc8sBcf9DYEqedigWepHwbZZUYYqk2M1TbmJSXj\nvQ04abqtfKbEvdLD+Sxbsd24SL9J1/GXqP2BxPKQWfvYjhU7gQsYTG1zfjanJ7AI\n4VrgQXekBd3sljGQU9odyeBhWC1NEjTyKtL/fOvShlkul7aG6iSowR74epXErg2k\nm2ZnVFby5eDJes0Nw1KoZkJ8rVpk1AUyeIaqc+GSLuRbEOAavX/1P2O4cCXJOno2\nbP7yCt4qRorKLq+RNTXPIqDStFTTiumGAw6n+oomQ87DrePctN5ORkDWr/QMzKBS\nSTUi0KM2zzs10x7jCKd/iiQ44wORVpLbP10D1LZ+oQKBgQD3YyDkfGtxuzoj/APf\nterlhWOTfSf/i9+fyjQVuAto9Tdmd7mPE8cwvCwzttmGkyIWWJPrLuyigGCrC8zv\nPjUtdRBEtXTLhyPeKNmgItO8VZWnPRpzJ8CnsXXdwVn44/CpHvG2UFXDXNioJ2g1\n0BAhi+L8c7kTTiYB/QTX9z0T+wKBgQDWQTm58lFGcFLu7nBT1apAACaW84zjJrAv\nq4vor4+h8ASM8gynlPc74Qfrf5Yn3nVFZhRtoWgd4MwDtdayArmX4zJUmN0mKZrK\nG6sDt97gHY0YebBtFCQWotb7KtXUMZXJ4IpyRD5SYDldSTK/JljCJuXx61Caw4c6\nweZbjfaI4QKBgQCMr40HI1KfDRCVYj55vKTm/iKQv749b7gu0Pkp2M50U++7kB6w\npVjD+F9S0YuHIqlh9+G2/6qHB2byHvXeoIvxW/9yc5cGH8ZgEu8gSG4NTsaaov8l\nudewBhW3lLur9UTpiLWBLtJ3FZgImNCEudxSl5DwbIc12V14CAH3J51OfQKBgQCs\nHH1o2DVd5kFY2oW1csBu5TAats8Icj26LY4Yf19ccNjW+GIeBNaObXjVPwq6QEPo\nWdYzMyPWTIzWti4flXzNfJ8jwiB01ZsYnB1GwV/ynQqJDMgi97j9zhXwcjqPWL3B\nC/VrUVLXDaFHRNPVJdLLNEAnlCaODGAHXVfVWDchQQKBgQDfObebo2KPP8aVokC5\n5NnzPrpzWNfl7asR7sf/HozpKDpT1NEoFptQo4zCe3dB6IyFvyQpJ+rgpyMrp/ut\nIRKXtzEz+LlRLLuIXIUyNbuK2o9ADHFvjQ88IVJ+Gg1PnSDUiVyr2X8hD/gbkU1W\n5kJQaH3Oru6GGQ8lhbvk2qo/fQ==\n-----END PRIVATE KEY-----\n", - client_email: "firebase-adminsdk-1djmt@miaajudadev.iam.gserviceaccount.com", - client_id: "105126767310578944074", - auth_uri: "https://accounts.google.com/o/oauth2/auth", - token_uri: "https://oauth2.googleapis.com/token", - auth_provider_x509_cert_url: "https://www.googleapis.com/oauth2/v1/certs", - client_x509_cert_url: - "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-1djmt%40miaajudadev.iam.gserviceaccount.com", -}; - -const databaseURL = "https://miaajudadev.firebaseio.com"; - -module.exports = { - config, - databaseURL, -}; From 571092ea97a44a35c14cdde6cb4fd93c9000f31a Mon Sep 17 00:00:00 2001 From: Welison Almeida Date: Thu, 18 Jun 2020 23:33:32 -0300 Subject: [PATCH 04/28] Review code and add eslint --- .eslintrc.json | 17 +- index.js | 22 +- package.json | 1 + src/config/authFirebase.js | 8 +- src/config/database.js | 31 +- src/controllers/CategoryController.js | 49 +- src/controllers/HelpController.js | 321 ++++++----- src/controllers/NotificationController.js | 26 +- src/controllers/UserController.js | 229 ++++---- src/models/Category.js | 24 +- src/models/Help.js | 134 +++-- src/models/Notification.js | 86 +-- src/models/Point.js | 18 +- src/models/RiskGroup.js | 24 +- src/models/User.js | 149 +++-- src/repository/BaseRepository.js | 10 +- src/repository/CategoryRepository.js | 24 +- src/repository/HelpRepository.js | 155 +++--- src/repository/NotificationRepository.js | 30 +- src/repository/UserRepository.js | 101 ++-- src/routes/BaseRoutes.js | 8 +- src/routes/CategoryRoutes.js | 6 +- src/routes/HelpRoutes.js | 26 +- src/routes/NotificationRoutes.js | 4 +- src/routes/UserRoutes.js | 36 +- src/services/CategoryService.js | 34 +- src/services/HelpService.js | 598 ++++++++++----------- src/services/NotificationService.js | 23 +- src/services/UserService.js | 28 +- src/utils/Notification.js | 91 ++-- src/utils/NotificationMixin.js | 32 +- src/utils/enums/helpStatusEnum.js | 14 +- src/utils/geolocation/calculateDistance.js | 23 +- src/utils/schedule.js | 105 ++-- src/utils/seed/CategorySeed.js | 114 ++-- src/utils/seed/HelpSeed.js | 39 +- src/utils/seed/NotificationSeed.js | 76 ++- src/utils/seed/UserSeed.js | 111 ++-- src/validation/middlewares/authFirebase.js | 30 +- websocket.js | 140 ++--- yarn.lock | 15 +- 41 files changed, 1510 insertions(+), 1502 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 52c528e0..b19a2e35 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -15,10 +15,23 @@ "ecmaVersion": 2018 }, "rules": { - "indent": ["error", 4], + "indent": [ + "error", + 2 + ], + "semi": [ + "error", + "always" + ], "no-underscore-dangle": 0, "no-param-reassign": 0, - "max-len": ["error", { "code": 120 }], + "no-console": 0, + "max-len": [ + "error", + { + "code": 120 + } + ], "no-useless-catch": 0, "class-methods-use-this": 0 } diff --git a/index.js b/index.js index 3242bae0..9a492141 100644 --- a/index.js +++ b/index.js @@ -1,21 +1,21 @@ -require("dotenv").config(); +require('dotenv').config(); -const bodyParser = require("body-parser"); -const cors = require("cors"); -const express = require("express"); -const http = require("http"); -const setRoutes = require("./src/routes/BaseRoutes"); -const dailySchedule = require("./src/utils/schedule"); -const { setupWebsocket } = require("./websocket"); +const bodyParser = require('body-parser'); +const cors = require('cors'); +const express = require('express'); +const http = require('http'); +const setRoutes = require('./src/routes/BaseRoutes'); +const dailySchedule = require('./src/utils/schedule'); +const { setupWebsocket } = require('./websocket'); const app = express(); const server = http.Server(app); -app.use(express.json({ limit: "50mb" })); -app.use(express.urlencoded({ limit: "50mb" })); +app.use(express.json({ limit: '50mb' })); +app.use(express.urlencoded({ limit: '50mb' })); setupWebsocket(server); -const databaseConnect = require("./src/config/database"); +const databaseConnect = require('./src/config/database'); app.use(cors()); app.use(bodyParser.json()); diff --git a/package.json b/package.json index 654e2483..47b5548b 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "faker": "^4.1.0", "firebase-admin": "^8.10.0", "lodash": "^4.17.15", + "mongodb": "^3.5.9", "mongoose": "^5.9.6", "node-schedule": "^1.3.2", "socket.io": "^2.3.0", diff --git a/src/config/authFirebase.js b/src/config/authFirebase.js index e10af93d..b5644fd1 100644 --- a/src/config/authFirebase.js +++ b/src/config/authFirebase.js @@ -1,11 +1,9 @@ - -const admin = require("firebase-admin"); - -const { config, databaseURL } = require("./firebaseConfig"); +const admin = require('firebase-admin'); +const { config, databaseURL } = require('./firebaseConfig'); admin.initializeApp({ credential: admin.credential.cert(config), - databaseURL: databaseURL + databaseURL, }); module.exports = admin; diff --git a/src/config/database.js b/src/config/database.js index 917ac906..5b9ae9b4 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -8,22 +8,25 @@ const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaD 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((error) => console.log('Não foi possível se conectar ao banco de dados!')); + 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 CategorySeed(); - // só popula usuários e ajudas falsos em desenvolvimento - if (envType === 'development') { - await UserSeed(); - await HelpSeed(); - await NotificationSeed(); - } - } catch (error) { - console.log('Não foi possível inicicializar corretamente a base de dados!'); - console.log(error); + await CategorySeed(); + // só popula usuários e ajudas falsos em desenvolvimento + if (envType === 'development') { + await UserSeed(); + await HelpSeed(); + await NotificationSeed(); } + } catch (error) { + console.log('Não foi possível inicicializar corretamente a base de dados!'); + console.log(error); + } }; module.exports = databaseConnect; diff --git a/src/controllers/CategoryController.js b/src/controllers/CategoryController.js index c3c3102f..503b13e2 100644 --- a/src/controllers/CategoryController.js +++ b/src/controllers/CategoryController.js @@ -1,34 +1,35 @@ const CategoryService = require('../services/CategoryService'); class CategoryController { - constructor() { - this.CategoryService = new CategoryService(); - } + constructor() { + this.CategoryService = new CategoryService(); + } + + async getCategoryById(req, res, next) { + const { id } = req.params; - async getCategoryById(req, res, next) { - const { id } = req.params; - try { - const result = await this.CategoryService.getCategoryByid(id); - res.status(200).json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + try { + const result = await this.CategoryService.getCategoryByid(id); + res.status(200).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } + } + + async getCategoryList(req, res, next) { + const id = req.query.id || null; - async getCategoryList(req, res, next) { - const id = req.query.id || null; - try { - let result; - result = await this.CategoryService.getCategoryList(id); - res.status(200).json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + try { + const result = await this.CategoryService.getCategoryList(id); + res.status(200).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } + } } module.exports = CategoryController; diff --git a/src/controllers/HelpController.js b/src/controllers/HelpController.js index 6cd9b119..969f9653 100644 --- a/src/controllers/HelpController.js +++ b/src/controllers/HelpController.js @@ -1,184 +1,179 @@ -const HelpService = require("../services/HelpService"); -const UserService = require("../services/UserService") +const HelpService = require('../services/HelpService'); +const UserService = require('../services/UserService'); class HelpController { - constructor() { - this.HelpService = new HelpService(); - this.UserService = new UserService(); + constructor() { + this.HelpService = new HelpService(); + this.UserService = new UserService(); + } + + async createHelp(req, res, next) { + const data = { + ...req.body, + }; + + try { + const result = await this.HelpService.createHelp(data); + res.status(201).json(result); + next(); + } catch (err) { + res.status(400).send({ error: err }); + next(); } - - async createHelp(req, res, next) { - const data = { - ...req.body, - }; - - try { - const result = await this.HelpService.createHelp(data); - - res.status(201).json(result); - next(); - } catch (err) { - res.status(400).send({ error: err }); - next(); - } - } - - async getHelpById(req, res, next) { - const { id } = req.params; - try { - const result = await this.HelpService.getHelpByid(id); - res.status(200).json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + } + + async getHelpById(req, res, next) { + const { id } = req.params; + + try { + const result = await this.HelpService.getHelpByid(id); + res.status(200).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } - - async getHelpList(req, res, next) { - const except = !!req.query["id.except"]; - const helper = !!req.query["id.helper"]; - const temp = except ? "except" : helper ? "helper" : null; - const id = temp ? req.query[`id.${temp}`] : req.query.id; - const status = req.query.status || null; - const categoryArray = req.query.categoryId - ? req.query.categoryId.split(",") - : null; - /* A requisição do Query é feita com o formato "34312ID12312,12312ID13213", + } + + async getHelpList(req, res, next) { + const except = !!req.query['id.except']; + const helper = !!req.query['id.helper']; + const temp = except ? 'except' : helper ? 'helper' : null; + const id = temp ? req.query[`id.${temp}`] : req.query.id; + const status = req.query.status || null; + const categoryArray = req.query.categoryId ? req.query.categoryId.split(',') : null; + /* A requisição do Query é feita com o formato "34312ID12312,12312ID13213", sendo que não é aceito o formato "34312ID12312, 12312ID13213" com espaço */ - const near = !!req.query.near; - const coords = near - ? req.query.coords.split(",").map((coord) => Number(coord)) - : null; - - try { - let result; - - if (near) { - result = await this.HelpService.getNearHelpList( - coords, - except, - id, - categoryArray - ); - } else { - result = await this.HelpService.getHelpList( - id, - status, - except, - helper, - categoryArray - ); - } - res.status(200); - res.json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + const near = !!req.query.near; + const coords = near ? req.query.coords.split(',').map((coord) => Number(coord)) : null; + + try { + let result; + if (near) { + result = await this.HelpService.getNearHelpList( + coords, + except, + id, + categoryArray, + ); + } else { + result = await this.HelpService.getHelpList( + id, + status, + except, + helper, + categoryArray, + ); + } + res.status(200); + res.json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } + } - async getHelpListByStatus(req,res, next) { - const { userId } = req.params + async getHelpListByStatus(req, res, next) { + const { userId } = req.params; - /* A lista de status deve vir numa query separada por vírgulas + /* A lista de status deve vir numa query separada por vírgulas * Ex.: (...)?statusList=on_going,finished */ - const statusList = req.query.statusList.split(",") - - // Por padrão é feito uma agregação procurando por um ownerId. Caso queira procurar por um helperId é necessário uma query - const helper = req.query.helper === 'true' - - - try { - const result = await this.HelpService.getHelpListByStatus({userId, statusList, helper}); - - res.status(200).json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + const statusList = req.query.statusList.split(','); + + // Por padrão é feito uma agregação procurando por um ownerId. + // Caso queira procurar por um helperId é necessário uma query + const helper = req.query.helper === 'true'; + + try { + const result = await this.HelpService.getHelpListByStatus({ userId, statusList, helper }); + res.status(200).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } - - async deleteHelpLogic(req, res, next) { - const { id } = req.params; - - try { - const result = await this.HelpService.deleteHelpLogically(id); - - res.status(200).json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + } + + async deleteHelpLogic(req, res, next) { + const { id } = req.params; + + try { + const result = await this.HelpService.deleteHelpLogically(id); + res.status(200).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } - - async helperConfirmation(req, res, next) { - const data = { ...req.params }; - try { - const result = await this.HelpService.helperConfirmation(data); - res.status(200).json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + } + + async helperConfirmation(req, res, next) { + const data = { ...req.params }; + + try { + const result = await this.HelpService.helperConfirmation(data); + res.status(200).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } - - async ownerConfirmation(req ,res ,next){ - const data = {...req.params}; - try { - const result = await this.HelpService.ownerConfirmation(data); - res.status(200).json(result); - next(); - } catch (err) { - res.status(400).json({error:err}); - next(); - } + } + + async ownerConfirmation(req, res, next) { + const data = { ...req.params }; + + try { + const result = await this.HelpService.ownerConfirmation(data); + res.status(200).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } - - async chooseHelper(req,res,next){ - const data = { ...req.params } - - try { - await this.HelpService.chooseHelper(data); - res.status(204).json(); - next(); - } catch (err) { - res.status(400).json({ error: err }); - } + } + + async chooseHelper(req, res, next) { + const data = { ...req.params }; + + try { + await this.HelpService.chooseHelper(data); + res.status(204).json(); + next(); + } catch (err) { + res.status(400).json({ error: err }); } - - async addPossibleHelpers(req, res, next) { - const id = req.params.idHelp; - const idHelper = req.params.idHelper; - - try { - await this.HelpService.addPossibleHelpers(id, idHelper); - res.status(204).json(); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + } + + async addPossibleHelpers(req, res, next) { + const id = req.params.idHelp; + const { idHelper } = req.params; + + try { + await this.HelpService.addPossibleHelpers(id, idHelper); + res.status(204).json(); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } - - async getToExpireList(req, res, next) { - try { - const result = await this.HelpService.getListToDelete() - res.status(200); - res.json(result); - next(); - } catch (err) { - res.status(400); - res.json(err); - next(); - } + } + + async getToExpireList(req, res, next) { + try { + const result = await this.HelpService.getListToDelete(); + res.status(200); + res.json(result); + next(); + } catch (err) { + res.status(400); + res.json(err); + next(); } + } } diff --git a/src/controllers/NotificationController.js b/src/controllers/NotificationController.js index b8bf5b62..ae0c08f7 100644 --- a/src/controllers/NotificationController.js +++ b/src/controllers/NotificationController.js @@ -1,22 +1,22 @@ const NotificationService = require('../services/NotificationService'); class NotificationController { - constructor() { - this.notificationService = new NotificationService(); - } + constructor() { + this.notificationService = new NotificationService(); + } - async getUserNotificationsById(req, res, next) { - const { id } = req.params; + async getUserNotificationsById(req, res, next) { + const { id } = req.params; - try { - const result = await this.notificationService.getUserNotificationsById(id); - res.status(200).json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + try { + const result = await this.notificationService.getUserNotificationsById(id); + res.status(200).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } + } } module.exports = NotificationController; diff --git a/src/controllers/UserController.js b/src/controllers/UserController.js index 652ec157..a7d948f6 100644 --- a/src/controllers/UserController.js +++ b/src/controllers/UserController.js @@ -1,136 +1,137 @@ -const UserService = require("../services/UserService"); -const { riskGroups } = require("../models/RiskGroup"); +const UserService = require('../services/UserService'); +const { riskGroups } = require('../models/RiskGroup'); class UserController { constructor() { this.userService = new UserService(); } - async createUser(req, res, next) { - const { latitude, longitude } = req.body; - - const location = { - type: "Point", - coordinates: [longitude, latitude], - }; - - const data = { - location, - ...req.body, - hasUser: req.query.hasUser === 'true' - }; - - try { - const result = await this.userService.createUser(data); - res.status(201).json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + async createUser(req, res, next) { + const { latitude, longitude } = req.body; + + const location = { + type: 'Point', + coordinates: [longitude, latitude], + }; + + const data = { + location, + ...req.body, + hasUser: req.query.hasUser === 'true', + }; + + try { + const result = await this.userService.createUser(data); + res.status(201).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } + } - async editUserById(req, res, next) { - const data = { - email: req.decodedToken.email, - photo: req.body.photo, - name: req.body.name, - phone: req.body.phone, - notificationToken: req.body.notificationToken, - deviceId: req.body.deviceId, - }; - try { - const result = await this.userService.editUserById(data); - res.status(200).json(result); - return next(); - } catch (err) { - res.status(400).json({ error: err }); - return next(); - } + async editUserById(req, res, next) { + const data = { + email: req.decodedToken.email, + photo: req.body.photo, + name: req.body.name, + phone: req.body.phone, + notificationToken: req.body.notificationToken, + deviceId: req.body.deviceId, + }; + try { + const result = await this.userService.editUserById(data); + res.status(200).json(result); + return next(); + } catch (err) { + res.status(400).json({ error: err }); + return next(); } + } - async editUserAddressById(req, res, next) { - const data = { - email: req.decodedToken.email, - cep: req.body.cep, - number: req.body.number, - city: req.body.city, - state: req.body.state, - complement: req.body.complement, - }; - - try { - const result = await this.userService.editUserAddressById(data); - res.status(200).json(result); - return next(); - } catch (err) { - res.status(400).json({ error: err }); - return next(); - } + async editUserAddressById(req, res, next) { + const data = { + email: req.decodedToken.email, + cep: req.body.cep, + number: req.body.number, + city: req.body.city, + state: req.body.state, + complement: req.body.complement, + }; + + try { + const result = await this.userService.editUserAddressById(data); + res.status(200).json(result); + return next(); + } catch (err) { + res.status(400).json({ error: err }); + return next(); } + } - async deleteUserLogic(req, res, next) { - const { email } = req.decodedToken; - - try { - const result = await this.userService.deleteUserLogically(email); - res.status(200).json(result); - return next(); - } catch (err) { - res.status(400).json({ error: err }); - return next(); - } - } + async deleteUserLogic(req, res, next) { + const { email } = req.decodedToken; - async getUserById(req, res, next) { - const data = { - id: req.params.id, - email: req.decodedToken.email, - }; - - try { - const result = await this.userService.getUser(data); - res.status(200).json(result); - next(); - } catch (err) { - res.status(404).json({ error: err }); - next(); - } + try { + const result = await this.userService.deleteUserLogically(email); + res.status(200).json(result); + return next(); + } catch (err) { + res.status(400).json({ error: err }); + return next(); } + } - async updateUserLocationById(req, res, next) { - const data = { - email: req.decodedToken.email, - latitude: req.body.latitude, - longitude: req.body.longitude, - }; - - try { - const result = await this.userService.updateUserLocationById(data); - res.status(200).json(result); - next(); - } catch (err) { - res.status(400).json({ error: err }); - next(); - } + async getUserById(req, res, next) { + const data = { + id: req.params.id, + email: req.decodedToken.email, + }; + + try { + const result = await this.userService.getUser(data); + res.status(200).json(result); + next(); + } catch (err) { + res.status(404).json({ error: err }); + next(); } - async checkUserExistence(req, res, next) { - const { value } = req.params - - try { - const result = await this.userService.checkUserExistence(value); - res.status(200).json(result); - next(); - } catch (err) { - res.status(404).json({ error: err }); - next(); - } + } + + async updateUserLocationById(req, res, next) { + const data = { + email: req.decodedToken.email, + latitude: req.body.latitude, + longitude: req.body.longitude, + }; + + try { + const result = await this.userService.updateUserLocationById(data); + res.status(200).json(result); + next(); + } catch (err) { + res.status(400).json({ error: err }); + next(); } + } + + async checkUserExistence(req, res, next) { + const { value } = req.params; - async getUserGroupRiskList(req, res, next) { - res.status(200).json(riskGroups); - next(); + try { + const result = await this.userService.checkUserExistence(value); + res.status(200).json(result); + next(); + } catch (err) { + res.status(404).json({ error: err }); + next(); } + } + + async getUserGroupRiskList(req, res, next) { + res.status(200).json(riskGroups); + next(); + } } module.exports = UserController; diff --git a/src/models/Category.js b/src/models/Category.js index 93a10834..f68e705c 100644 --- a/src/models/Category.js +++ b/src/models/Category.js @@ -1,18 +1,18 @@ const mongoose = require('mongoose'); const categorySchema = new mongoose.Schema({ - name: { - type: String, - required: true, - }, - description: { - type: String, - required: true, - }, - active: { - default: true, - type: Boolean, - }, + name: { + type: String, + required: true, + }, + description: { + type: String, + required: true, + }, + active: { + default: true, + type: Boolean, + }, }, { collection: 'category' }); module.exports = mongoose.model('Category', categorySchema); diff --git a/src/models/Help.js b/src/models/Help.js index 86daeef7..6dd49872 100644 --- a/src/models/Help.js +++ b/src/models/Help.js @@ -1,74 +1,72 @@ -const mongoose = require("mongoose"); -const helpStatusEnum = require("../utils/enums/helpStatusEnum"); +const mongoose = require('mongoose'); +const helpStatusEnum = require('../utils/enums/helpStatusEnum'); -const helpSchema = new mongoose.Schema( - { - title: { - type: String, - required: true, - }, - description: { - type: String, - maxlength: 300, - required: true, - }, - status: { - type: String, - enum: Object.values(helpStatusEnum), - default: helpStatusEnum.WAITING, - }, - possibleHelpers: { - type: [mongoose.Schema.Types.ObjectId], - ref: "User", - required: false, - }, - categoryId: { - type: mongoose.Schema.Types.ObjectId, - ref: "Category", - }, - ownerId: { - type: mongoose.Schema.Types.ObjectId, - ref: "User", - required: true, - }, - helperId: { - type: mongoose.Schema.Types.ObjectId, - ref: "User", - required: false, - }, - creationDate: { - type: Date, - default: Date.now, - }, - finishedDate: { - type: Date, - required: false, - }, - active: { - default: true, - type: Boolean, - }, +const helpSchema = new mongoose.Schema({ + title: { + type: String, + required: true, }, - { - collection: "userHelp", - toObject: { - virtuals: true, - }, - toJSON: { - virtuals: true, - }, - } -); + description: { + type: String, + maxlength: 300, + required: true, + }, + status: { + type: String, + enum: Object.values(helpStatusEnum), + default: helpStatusEnum.WAITING, + }, + possibleHelpers: { + type: [mongoose.Schema.Types.ObjectId], + ref: 'User', + required: false, + }, + categoryId: { + type: mongoose.Schema.Types.ObjectId, + ref: 'Category', + }, + ownerId: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + required: true, + }, + helperId: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + required: false, + }, + creationDate: { + type: Date, + default: Date.now, + }, + finishedDate: { + type: Date, + required: false, + }, + active: { + default: true, + type: Boolean, + }, +}, +{ + collection: 'userHelp', + toObject: { + virtuals: true, + }, + toJSON: { + virtuals: true, + }, +}); -helpSchema.virtual("category", { - ref: "Category", - localField: "categoryId", - foreignField: "_id", +helpSchema.virtual('category', { + ref: 'Category', + localField: 'categoryId', + foreignField: '_id', }); -helpSchema.virtual("user", { - ref: "User", - localField: "ownerId", - foreignField: "_id", +helpSchema.virtual('user', { + ref: 'User', + localField: 'ownerId', + foreignField: '_id', }); -module.exports = mongoose.model("Help", helpSchema); +module.exports = mongoose.model('Help', helpSchema); diff --git a/src/models/Notification.js b/src/models/Notification.js index 8dd40c2a..0394f010 100644 --- a/src/models/Notification.js +++ b/src/models/Notification.js @@ -1,57 +1,57 @@ const mongoose = require('mongoose'); const notificationTypes = { - ajudaRecebida: 'Seu pedido recebeu uma oferta de ajuda!', - ajudaAceita: 'Sua oferta de ajuda foi aceita!', - ajudaFinalizada: 'Seu pedido de ajuda foi finalizado!', - ajudaExpirada: 'Seu pedido de ajuda expirou!', - outros: 'Demais tipos de notificação!', + ajudaRecebida: 'Seu pedido recebeu uma oferta de ajuda!', + ajudaAceita: 'Sua oferta de ajuda foi aceita!', + ajudaFinalizada: 'Seu pedido de ajuda foi finalizado!', + ajudaExpirada: 'Seu pedido de ajuda expirou!', + outros: 'Demais tipos de notificação!', }; const notificationTypesEnum = { - ajudaRecebida: 'ajudaRecebida', - ajudaAceita: 'ajudaAceita', - ajudaFinalizada: 'ajudaFinalizada', - ajudaExpirada: 'ajudaExpirada', - outros: 'outros', + ajudaRecebida: 'ajudaRecebida', + ajudaAceita: 'ajudaAceita', + ajudaFinalizada: 'ajudaFinalizada', + ajudaExpirada: 'ajudaExpirada', + outros: 'outros', }; const NotificationSchema = new mongoose.Schema({ - userId: { - type: mongoose.Schema.Types.ObjectId, - ref: 'User', - required: false, - }, - helpId: { - type: mongoose.Schema.Types.ObjectId, - ref: 'Help', - required: false, - }, - title: { - type: String, - required: true, - }, - body: { - type: String, - required: true, - }, - registerDate: { - type: Date, - required: true, - default: Date.now, - }, - notificationType: { - type: String, - enum: [...Object.keys(notificationTypesEnum)], - }, -}, { - collection: 'notification', + userId: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + required: false, + }, + helpId: { + type: mongoose.Schema.Types.ObjectId, + ref: 'Help', + required: false, + }, + title: { + type: String, + required: true, + }, + body: { + type: String, + required: true, + }, + registerDate: { + type: Date, + required: true, + default: Date.now, + }, + notificationType: { + type: String, + enum: [...Object.keys(notificationTypesEnum)], + }, +}, { + collection: 'notification', }); const Notification = mongoose.model('Notification', NotificationSchema); module.exports = { - Notification, - notificationTypes, - notificationTypesEnum -} + Notification, + notificationTypes, + notificationTypesEnum, +}; diff --git a/src/models/Point.js b/src/models/Point.js index c9dff170..6be0855f 100644 --- a/src/models/Point.js +++ b/src/models/Point.js @@ -1,15 +1,15 @@ const mongoose = require('mongoose'); const Point = new mongoose.Schema({ - type: { - type: String, - enum: ['Point'], - required: true, - }, - coordinates: { - type: [Number], - required: true, - }, + type: { + type: String, + enum: ['Point'], + required: true, + }, + coordinates: { + type: [Number], + required: true, + }, }); module.exports = Point; diff --git a/src/models/RiskGroup.js b/src/models/RiskGroup.js index 233612d7..7a783245 100644 --- a/src/models/RiskGroup.js +++ b/src/models/RiskGroup.js @@ -1,20 +1,20 @@ const riskGroups = { - dc: 'Doença respiratória', - hiv: 'HIV', - diab: 'Diabetes', - hiperT: 'Hipertensão', - doenCardio: 'Doenças cardiovasculares', + dc: 'Doença respiratória', + hiv: 'HIV', + diab: 'Diabetes', + hiperT: 'Hipertensão', + doenCardio: 'Doenças cardiovasculares', }; const riskGroupsEnum = { - dc: 'dc', // Doença respiratória, - hiv: 'hiv', // HIV, - diab: 'diab', // Diabetes, - hiperT: 'hiperT', // Hipertensão, - doenCardio: 'doenCardio', // 'Doenças cardiovasculares', + dc: 'dc', // Doença respiratória + hiv: 'hiv', // HIV + diab: 'diab', // Diabetes + hiperT: 'hiperT', // Hipertensão + doenCardio: 'doenCardio', // Doenças cardiovasculares }; module.exports = { - riskGroups, - riskGroupsEnum, + riskGroups, + riskGroupsEnum, }; diff --git a/src/models/User.js b/src/models/User.js index 0c83574f..af648a68 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -1,90 +1,87 @@ const mongoose = require('mongoose'); const { cpf } = require('cpf-cnpj-validator'); - const Point = require('./Point'); - - const { riskGroupsEnum } = require('./RiskGroup'); const userSchema = new mongoose.Schema({ - name: { - type: String, - required: true, - }, - deviceId: { - type: String, - required: false, - }, - email: { - type: String, - required: true, - unique: true, - index: true, - }, - birthday: { - type: Date, - required: true, - }, - cpf: { - type: String, - required: true, - unique: true, - index: true, - validate: { - validator: (v) => cpf.isValid(v), - message: (props) => `${props.value} não é um cpf válido`, - }, - }, - riskGroup: { - type: [String], - enum: [...Object.keys(riskGroupsEnum)], - }, - photo: { - type: String, - required: true, - }, - notificationToken: { - type: String, - }, - address: { - cep: { - type: String, - required: true, - }, - number: { - type: Number, - required: true, - }, - city: { - type: String, - required: true, - }, - state: { - type: String, - required: true, - }, - complement: String, - }, - ismentalHealthProfessional: { - type: Boolean, - default: false, + name: { + type: String, + required: true, + }, + deviceId: { + type: String, + required: false, + }, + email: { + type: String, + required: true, + unique: true, + index: true, + }, + birthday: { + type: Date, + required: true, + }, + cpf: { + type: String, + required: true, + unique: true, + index: true, + validate: { + validator: (v) => cpf.isValid(v), + message: (props) => `${props.value} não é um cpf válido`, }, - location: { - type: Point, - index: '2dsphere', + }, + riskGroup: { + type: [String], + enum: [...Object.keys(riskGroupsEnum)], + }, + photo: { + type: String, + required: true, + }, + notificationToken: { + type: String, + }, + address: { + cep: { + type: String, + required: true, }, - phone: { - type: String, - required: true, + number: { + type: Number, + required: true, }, - registerDate: { - type: Date, - default: Date.now, + city: { + type: String, + required: true, }, - active: { - default: true, - type: Boolean, + state: { + type: String, + required: true, }, + complement: String, + }, + ismentalHealthProfessional: { + type: Boolean, + default: false, + }, + location: { + type: Point, + index: '2dsphere', + }, + phone: { + type: String, + required: true, + }, + registerDate: { + type: Date, + default: Date.now, + }, + active: { + default: true, + type: Boolean, + }, }, { collection: 'user' }); module.exports = mongoose.model('User', userSchema); diff --git a/src/repository/BaseRepository.js b/src/repository/BaseRepository.js index 5858b159..0063d54a 100644 --- a/src/repository/BaseRepository.js +++ b/src/repository/BaseRepository.js @@ -1,4 +1,4 @@ -const mongoose = require("mongoose"); +const mongoose = require('mongoose'); class BaseRepository { constructor(modelClass) { @@ -32,8 +32,10 @@ class BaseRepository { } async $listAggregate(aggregationPipeline) { - return await this.modelClass.aggregate(aggregationPipeline).exec(); + const aggregatedPipeline = await this.modelClass.aggregate(aggregationPipeline).exec(); + return aggregatedPipeline; } + /** * @param {string} id Id do objeto * @param {Boolean} [active = true] se vou pegar ou não elementos deletados, @@ -42,11 +44,11 @@ class BaseRepository { async $getById(id, active = true) { let finalIdFormat = id; - if (typeof id === "string") { + if (typeof id === 'string') { try { finalIdFormat = mongoose.Types.ObjectId(id); } catch (err) { - throw "Tamanho ou formato de id inválido"; + throw 'Tamanho ou formato de id inválido'; } } diff --git a/src/repository/CategoryRepository.js b/src/repository/CategoryRepository.js index 3f8fe465..7581a7a9 100644 --- a/src/repository/CategoryRepository.js +++ b/src/repository/CategoryRepository.js @@ -2,20 +2,20 @@ const BaseRepository = require('./BaseRepository'); const CategorySchema = require('../models/Category'); class CategoryRepository extends BaseRepository { - constructor() { - super(CategorySchema); - } + constructor() { + super(CategorySchema); + } - async getById(id) { - const result = await super.$getById(id); - return result; - } + async getById(id) { + const result = await super.$getById(id); + return result; + } - async list(id) { - const query = id ? {id} : {}; - const result = await super.$list(query); - return result; - } + async list(id) { + const query = id ? { id } : {}; + const result = await super.$list(query); + return result; + } } module.exports = CategoryRepository; diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index a0cd0813..4b8f7995 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -1,8 +1,8 @@ -const BaseRepository = require("./BaseRepository"); -const HelpSchema = require("../models/Help"); -const UserSchema = require("../models/User"); -const ObjectId = require("mongodb").ObjectID; -const { getDistance } = require("../utils/geolocation/calculateDistance"); +const { ObjectID } = require('mongodb'); +const BaseRepository = require('./BaseRepository'); +const HelpSchema = require('../models/Help'); +const UserSchema = require('../models/User'); +const { getDistance } = require('../utils/geolocation/calculateDistance'); class HelpRepository extends BaseRepository { constructor() { @@ -18,24 +18,24 @@ class HelpRepository extends BaseRepository { }, { $lookup: { - from: "user", - localField: "ownerId", - foreignField: "_id", - as: "user", + from: 'user', + localField: 'ownerId', + foreignField: '_id', + as: 'user', }, }, { $unwind: { - path: "$user", + path: '$user', preserveNullAndEmptyArrays: false, }, }, { $lookup: { - from: "category", - localField: "categoryId", - foreignField: "_id", - as: "category", + from: 'category', + localField: 'categoryId', + foreignField: '_id', + as: 'category', }, }, ]; @@ -43,21 +43,24 @@ class HelpRepository extends BaseRepository { const helps = await super.$listAggregate(aggregation); return helps[0]; } + async getById(id) { - return await super.$getById(id); + const help = await super.$getById(id); + return help; } async update(help) { - return await super.$update(help); + const helpUpdated = await super.$update(help); + return helpUpdated; } async list(id, status, except, helper, categoryArray) { const ownerId = except - ? { $ne: ObjectId(id) } + ? { $ne: ObjectID(id) } : helper - ? null - : ObjectId(id); - const helperId = helper ? ObjectId(id) : null; + ? null + : ObjectID(id); + const helperId = helper ? ObjectID(id) : null; const query = {}; if (status) query.status = status; if (categoryArray) query.categoryId = { $in: categoryArray }; @@ -70,15 +73,15 @@ class HelpRepository extends BaseRepository { }, { $lookup: { - from: "user", - localField: "ownerId", - foreignField: "_id", - as: "user", + from: 'user', + localField: 'ownerId', + foreignField: '_id', + as: 'user', }, }, { $unwind: { - path: "$user", + path: '$user', preserveNullAndEmptyArrays: false, }, }, @@ -91,10 +94,10 @@ class HelpRepository extends BaseRepository { { $subtract: [ { - $year: "$$NOW", + $year: '$$NOW', }, { - $year: "$user.birthday", + $year: '$user.birthday', }, ], }, @@ -108,14 +111,14 @@ class HelpRepository extends BaseRepository { cardio: { $cond: [ { - $in: ["$user.riskGroup", [["doenCardio"]]], + $in: ['$user.riskGroup', [['doenCardio']]], }, 1, 0, ], }, risco: { - $size: "$user.riskGroup", + $size: '$user.riskGroup', }, }, }, @@ -135,18 +138,18 @@ class HelpRepository extends BaseRepository { }, { $lookup: { - from: "category", - localField: "categoryId", - foreignField: "_id", - as: "category", + from: 'category', + localField: 'categoryId', + foreignField: '_id', + as: 'category', }, }, { $lookup: { - from: "user", - localField: "possibleHelpers", - foreignField: "_id", - as: "possibleHelpers", + from: 'user', + localField: 'possibleHelpers', + foreignField: '_id', + as: 'possibleHelpers', }, }, ]); @@ -158,7 +161,7 @@ class HelpRepository extends BaseRepository { const location = { $near: { $geometry: { - type: "Point", + type: 'Point', coordinates: coords, }, $maxDistance: 2000, @@ -172,18 +175,18 @@ class HelpRepository extends BaseRepository { const users = await UserSchema.find(query); const arrayUsersId = users.map((user) => user._id); - let matchQuery = {}; + const matchQuery = {}; matchQuery.active = true; - matchQuery.possibleHelpers = { $not: { $in: [ObjectId(id)] } }; + matchQuery.possibleHelpers = { $not: { $in: [ObjectID(id)] } }; matchQuery.ownerId = { $in: arrayUsersId, }; - matchQuery.status = "waiting"; + matchQuery.status = 'waiting'; if (categoryArray) { matchQuery.categoryId = { - $in: categoryArray.map((categoryString) => ObjectId(categoryString)), + $in: categoryArray.map((categoryString) => ObjectID(categoryString)), }; } const aggregation = [ @@ -192,15 +195,15 @@ class HelpRepository extends BaseRepository { }, { $lookup: { - from: "user", - localField: "ownerId", - foreignField: "_id", - as: "user", + from: 'user', + localField: 'ownerId', + foreignField: '_id', + as: 'user', }, }, { $unwind: { - path: "$user", + path: '$user', preserveNullAndEmptyArrays: false, }, }, @@ -213,10 +216,10 @@ class HelpRepository extends BaseRepository { { $subtract: [ { - $year: "$$NOW", + $year: '$$NOW', }, { - $year: "$user.birthday", + $year: '$user.birthday', }, ], }, @@ -230,14 +233,14 @@ class HelpRepository extends BaseRepository { cardio: { $cond: [ { - $in: ["$user.riskGroup", [["doenCardio"]]], + $in: ['$user.riskGroup', [['doenCardio']]], }, 1, 0, ], }, risco: { - $size: "$user.riskGroup", + $size: '$user.riskGroup', }, }, }, @@ -257,18 +260,18 @@ class HelpRepository extends BaseRepository { }, { $lookup: { - from: "category", - localField: "categoryId", - foreignField: "_id", - as: "category", + from: 'category', + localField: 'categoryId', + foreignField: '_id', + as: 'category', }, }, { $lookup: { - from: "user", - localField: "possibleHelpers", - foreignField: "_id", - as: "possibleHelpers", + from: 'user', + localField: 'possibleHelpers', + foreignField: '_id', + as: 'possibleHelpers', }, }, ]; @@ -299,7 +302,7 @@ class HelpRepository extends BaseRepository { const query = {}; query.ownerId = id; query.active = true; - query.status = { $ne: "finished" }; + query.status = { $ne: 'finished' }; const result = await super.$countDocuments(query); return result; @@ -326,14 +329,14 @@ class HelpRepository extends BaseRepository { if (helper) { matchQuery.$or = [ { - possibleHelpers: { $in: [ObjectId(userId)] }, + possibleHelpers: { $in: [ObjectID(userId)] }, }, { - helperId: ObjectId(userId), + helperId: ObjectID(userId), }, ]; } else { - matchQuery.ownerId = ObjectId(userId); + matchQuery.ownerId = ObjectID(userId); } const helpList = await super.$listAggregate([ { @@ -341,31 +344,31 @@ class HelpRepository extends BaseRepository { }, { $lookup: { - from: "user", - localField: "possibleHelpers", - foreignField: "_id", - as: "possibleHelpers", + from: 'user', + localField: 'possibleHelpers', + foreignField: '_id', + as: 'possibleHelpers', }, }, { $lookup: { - from: "user", - localField: "ownerId", - foreignField: "_id", - as: "user", + from: 'user', + localField: 'ownerId', + foreignField: '_id', + as: 'user', }, }, { $lookup: { - from: "category", - localField: "categoryId", - foreignField: "_id", - as: "category", + from: 'category', + localField: 'categoryId', + foreignField: '_id', + as: 'category', }, }, { $unwind: { - path: "$user", + path: '$user', preserveNullAndEmptyArrays: false, }, }, diff --git a/src/repository/NotificationRepository.js b/src/repository/NotificationRepository.js index 66ef4407..3b13ae71 100644 --- a/src/repository/NotificationRepository.js +++ b/src/repository/NotificationRepository.js @@ -2,23 +2,23 @@ const BaseRepository = require('./BaseRepository'); const { Notification: NotificationSchema } = require('../models/Notification'); class NotificationRepository extends BaseRepository { - constructor() { - super(NotificationSchema); - } + constructor() { + super(NotificationSchema); + } - async create(notification) { - const result = await super.$save(notification); - - return result; - } + async create(notification) { + const result = await super.$save(notification); - async getUserNotificationsById(id) { - const result = await NotificationSchema.find({"userId": id}) - .sort({"registerDate": -1}) - .limit(30); - - return result; - } + return result; + } + + async getUserNotificationsById(id) { + const result = await NotificationSchema.find({ userId: id }) + .sort({ registerDate: -1 }) + .limit(30); + + return result; + } } module.exports = NotificationRepository; diff --git a/src/repository/UserRepository.js b/src/repository/UserRepository.js index d0285aa7..ae0a5052 100644 --- a/src/repository/UserRepository.js +++ b/src/repository/UserRepository.js @@ -1,62 +1,61 @@ const BaseRepository = require('./BaseRepository'); const UserSchema = require('../models/User'); - class UserRepository extends BaseRepository { - constructor() { - super(UserSchema); + constructor() { + super(UserSchema); + } + + async create(user) { + const result = await super.$save(user); + return result; + } + + async getById(id) { + const result = await super.$getById(id); + return result; + } + + async getUserByEmail(email) { + const result = await super.$list({ email }); + return result[0]; + } + + async update(user) { + const result = await super.$update(user); + return result; + } + + async checkUserExistence(id) { + const users = await super.$listAggregate([ + { + $match: { + $or: [ + { cpf: id }, + { email: id }, + ], + }, + }, { + $count: 'id', + }, + ]); + + let result = 0; + + if (users[0] && users[0].id > 0) { + result = users[0].id; } - async create(user) { - const result = await super.$save(user); - return result; - } + return result; + } - async getById(id) { - const result = await super.$getById(id); - return result; - } - - async getUserByEmail(email) { - const result = await super.$list({email}); - return result[0]; - } + async removeUser({ id, email }) { + const query = {}; + query._id = id; + query.email = email; - async update(user) { - const result = await super.$update(user); - return result; - } - - async checkUserExistence(id) { - const users = await super.$listAggregate([ - { - '$match': { - '$or': [ - { 'cpf': id }, - { 'email': id } - ] - } - }, { - '$count': 'id' - } - ]); - - let result = 0 - - if (users[0] && users[0].id > 0) { - result = users[0].id - } - - return result; - } - - async removeUser({id, email}) { - const query = {} - query._id = id - query.email = email - - await super.$destroy(query); - } + await super.$destroy(query); + } } module.exports = UserRepository; diff --git a/src/routes/BaseRoutes.js b/src/routes/BaseRoutes.js index 8b4361ba..0050379f 100644 --- a/src/routes/BaseRoutes.js +++ b/src/routes/BaseRoutes.js @@ -1,13 +1,13 @@ +const YAML = require('yamljs'); +const swaggerUi = require('swagger-ui-express'); const userRoutes = require('./UserRoutes'); const helpRoutes = require('./HelpRoutes'); const categoryRoutes = require('./CategoryRoutes'); const notificationRoutes = require('./NotificationRoutes'); -const YAML = require('yamljs'); -const swaggerUi = require('swagger-ui-express'); const swaggerDocument = YAML.load('docs/swagger.yaml'); module.exports = (app) => { - app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); - app.use('/api', [userRoutes, helpRoutes, categoryRoutes, notificationRoutes]); + app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); + app.use('/api', [userRoutes, helpRoutes, categoryRoutes, notificationRoutes]); }; diff --git a/src/routes/CategoryRoutes.js b/src/routes/CategoryRoutes.js index a5b2bd5c..8022a57b 100644 --- a/src/routes/CategoryRoutes.js +++ b/src/routes/CategoryRoutes.js @@ -1,15 +1,15 @@ const express = require('express'); const CategoryController = require('../controllers/CategoryController'); - const categoryController = new CategoryController(); const routes = express.Router(); routes.get('/category/:id', async (req, res, next) => { - categoryController.getCategoryById(req, res, next); + categoryController.getCategoryById(req, res, next); }); + routes.get('/category', async (req, res, next) => { - categoryController.getCategoryList(req, res, next); + categoryController.getCategoryList(req, res, next); }); module.exports = routes; diff --git a/src/routes/HelpRoutes.js b/src/routes/HelpRoutes.js index 239ce2df..02a2e39f 100644 --- a/src/routes/HelpRoutes.js +++ b/src/routes/HelpRoutes.js @@ -1,44 +1,44 @@ const express = require('express'); const HelpController = require('../controllers/HelpController'); -const isAuthenticated = require("../validation/middlewares/authFirebase"); +const isAuthenticated = require('../validation/middlewares/authFirebase'); const helpController = new HelpController(); const routes = express.Router(); - routes.post('/help', isAuthenticated, async (req, res, next) => { - helpController.createHelp(req, res, next); + helpController.createHelp(req, res, next); }); + routes.get('/help/:id', isAuthenticated, async (req, res, next) => { - helpController.getHelpById(req, res, next); + helpController.getHelpById(req, res, next); }); routes.get('/help', isAuthenticated, async (req, res, next) => { - helpController.getHelpList(req, res, next); + helpController.getHelpList(req, res, next); }); routes.get('/help/listbyStatus/:userId', async (req, res, next) => { - helpController.getHelpListByStatus(req, res, next); + helpController.getHelpListByStatus(req, res, next); }); routes.delete('/help/:id', isAuthenticated, async (req, res, next) => { - helpController.deleteHelpLogic(req, res, next); + helpController.deleteHelpLogic(req, res, next); }); routes.put('/help/helperConfirmation/:helpId/:helperId', isAuthenticated, async (req, res, next) => { - helpController.helperConfirmation(req, res, next); + helpController.helperConfirmation(req, res, next); }); routes.put('/help/ownerConfirmation/:helpId/:ownerId', isAuthenticated, async (req, res, next) => { - helpController.ownerConfirmation(req, res, next); + helpController.ownerConfirmation(req, res, next); }); -routes.put('/help/chooseHelper/:idHelp/:idHelper', isAuthenticated, async (req, res, next) =>{ - helpController.chooseHelper(req,res,next); +routes.put('/help/chooseHelper/:idHelp/:idHelper', isAuthenticated, async (req, res, next) => { + helpController.chooseHelper(req, res, next); }); -routes.put('/help/possibleHelpers/:idHelp/:idHelper', isAuthenticated, async(req,res,next)=>{ - helpController.addPossibleHelpers(req,res,next); +routes.put('/help/possibleHelpers/:idHelp/:idHelper', isAuthenticated, async (req, res, next) => { + helpController.addPossibleHelpers(req, res, next); }); module.exports = routes; diff --git a/src/routes/NotificationRoutes.js b/src/routes/NotificationRoutes.js index 5c67178d..b4dec354 100644 --- a/src/routes/NotificationRoutes.js +++ b/src/routes/NotificationRoutes.js @@ -1,12 +1,12 @@ const express = require('express'); const NotificationController = require('../controllers/NotificationController'); -const isAuthenticated = require("../validation/middlewares/authFirebase"); +const isAuthenticated = require('../validation/middlewares/authFirebase'); const notificationController = new NotificationController(); const routes = express.Router(); routes.get('/notification/user/:id', isAuthenticated, async (req, res, next) => { - notificationController.getUserNotificationsById(req, res, next); + notificationController.getUserNotificationsById(req, res, next); }); module.exports = routes; diff --git a/src/routes/UserRoutes.js b/src/routes/UserRoutes.js index d8c66422..3e526acf 100644 --- a/src/routes/UserRoutes.js +++ b/src/routes/UserRoutes.js @@ -1,35 +1,39 @@ -const express = require("express"); -const routes = express.Router(); +const express = require('express'); +const UserController = require('../controllers/UserController'); +const isAuthenticated = require('../validation/middlewares/authFirebase'); -const UserController = require("../controllers/UserController"); +const routes = express.Router(); const userController = new UserController(); -const isAuthenticated = require("../validation/middlewares/authFirebase"); - - -routes.post("/user", async (req, res, next) => { - userController.createUser(req, res, next); +routes.post('/user', async (req, res, next) => { + userController.createUser(req, res, next); }); + routes.get('/user/getUser/:id*?/', isAuthenticated, async (req, res, next) => { - userController.getUserById(req, res, next) -}) + userController.getUserById(req, res, next); +}); + routes.put('/user', isAuthenticated, async (req, res, next) => { - userController.editUserById(req, res, next); + userController.editUserById(req, res, next); }); + routes.put('/user/address', isAuthenticated, async (req, res, next) => { - userController.editUserAddressById(req, res, next); + userController.editUserAddressById(req, res, next); }); routes.put('/user/location', isAuthenticated, async (req, res, next) => { - userController.updateUserLocationById(req, res, next); + userController.updateUserLocationById(req, res, next); }); + routes.delete('/user', isAuthenticated, async (req, res, next) => { - userController.deleteUserLogic(req, res, next); + userController.deleteUserLogic(req, res, next); }); + routes.get('/groupRisk', async (req, res, next) => { - userController.getUserGroupRiskList(req, res, next); + userController.getUserGroupRiskList(req, res, next); }); + routes.get('/checkUserExistence/:value', async (req, res, next) => { - userController.checkUserExistence(req, res, next); + userController.checkUserExistence(req, res, next); }); module.exports = routes; diff --git a/src/services/CategoryService.js b/src/services/CategoryService.js index 36c7850d..1d1625a1 100644 --- a/src/services/CategoryService.js +++ b/src/services/CategoryService.js @@ -1,30 +1,28 @@ const CategoryRepository = require('../repository/CategoryRepository'); class CategoryService { - constructor() { - this.CategoryRepository = new CategoryRepository(); - } + constructor() { + this.CategoryRepository = new CategoryRepository(); + } - async getCategoryByid(id) { - - const Category = await this.CategoryRepository.getById(id); - - - if (!Category) { - throw 'Categoria não encontrada'; - } + async getCategoryByid(id) { + const Category = await this.CategoryRepository.getById(id); - return Category; + if (!Category) { + throw 'Categoria não encontrada'; } - async getCategoryList(id) { - const Categorylist = await this.CategoryRepository.list(id); - if (!Categorylist) { - throw 'Categorias não encontrada'; - } + return Category; + } - return Categorylist; + async getCategoryList(id) { + const Categorylist = await this.CategoryRepository.list(id); + if (!Categorylist) { + throw 'Categorias não encontrada'; } + + return Categorylist; + } } module.exports = CategoryService; diff --git a/src/services/HelpService.js b/src/services/HelpService.js index be82ba7a..4b4e6659 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -1,343 +1,335 @@ -const HelpRepository = require("../repository/HelpRepository"); +const HelpRepository = require('../repository/HelpRepository'); const NotificationService = require('./NotificationService'); const { notificationTypesEnum } = require('../models/Notification'); -const UserService = require("./UserService"); -const CategoryService = require("./CategoryService"); +const UserService = require('./UserService'); +const CategoryService = require('./CategoryService'); const { findConnections, sendMessage } = require('../../websocket'); -const NotificationMixin = require("../utils/NotificationMixin"); -const helpStatusEnum = require("../utils/enums/helpStatusEnum") +const NotificationMixin = require('../utils/NotificationMixin'); +const helpStatusEnum = require('../utils/enums/helpStatusEnum'); class HelpService { - constructor() { - this.HelpRepository = new HelpRepository(); - this.UserService = new UserService(); - this.CategoryService = new CategoryService(); - this.NotificationService = new NotificationService(); - this.NotificationMixin = new NotificationMixin(); + constructor() { + this.HelpRepository = new HelpRepository(); + this.UserService = new UserService(); + this.CategoryService = new CategoryService(); + this.NotificationService = new NotificationService(); + this.NotificationMixin = new NotificationMixin(); + } + + async createHelp(data) { + const countHelp = await this.HelpRepository.countDocuments(data.ownerId); + if (countHelp >= 5) { + throw 'Limite máximo de pedidos atingido'; } - async createHelp(data) { - const countHelp = await this.HelpRepository.countDocuments(data.ownerId); - if (countHelp >= 5) { - throw "Limite máximo de pedidos atingido"; - } - - await this.CategoryService.getCategoryByid(data.categoryId); - - const createdHelp = await this.HelpRepository.create(data); - - const user = await this.UserService.getUser({ id: createdHelp.ownerId }); - const userCoords = { - longitude: user.location.coordinates[0], - latitude: user.location.coordinates[1], - }; - const sendSocketMessageTo = findConnections( - userCoords, - createdHelp.categoryId, - JSON.parse(JSON.stringify(user._id)) - ); - sendMessage(sendSocketMessageTo, "new-help", createdHelp); - - return createdHelp; - } + await this.CategoryService.getCategoryByid(data.categoryId); + + const createdHelp = await this.HelpRepository.create(data); + + const user = await this.UserService.getUser({ id: createdHelp.ownerId }); + const userCoords = { + longitude: user.location.coordinates[0], + latitude: user.location.coordinates[1], + }; + const sendSocketMessageTo = findConnections( + userCoords, + createdHelp.categoryId, + JSON.parse(JSON.stringify(user._id)), + ); + sendMessage(sendSocketMessageTo, 'new-help', createdHelp); - async getHelpByid(id) { - const Help = await this.HelpRepository.getById(id); + return createdHelp; + } - if (!Help) { - throw "Ajuda não encontrada"; - } + async getHelpByid(id) { + const Help = await this.HelpRepository.getById(id); - return Help; + if (!Help) { + throw 'Ajuda não encontrada'; } + return Help; + } - async getHelpList(id, status, category, except, helper) { - const Helplist = await this.HelpRepository.list( - id, - status, - category, - except, - helper - ); - if (!Helplist) { - throw "Nenhuma Ajuda com esse status foi encontrada"; - } - return Helplist; + async getHelpList(id, status, category, except, helper) { + const Helplist = await this.HelpRepository.list( + id, + status, + category, + except, + helper, + ); + if (!Helplist) { + throw 'Nenhuma Ajuda com esse status foi encontrada'; } - async getNearHelpList(coords, except, id, categoryArray) { - const Helplist = await this.HelpRepository.listNear( - coords, - except, - id, - categoryArray, - ); - if (!Helplist) { - throw "Pedidos de ajuda não encontrados no seu raio de distância" - } - - return Helplist; + return Helplist; + } + + async getNearHelpList(coords, except, id, categoryArray) { + const Helplist = await this.HelpRepository.listNear( + coords, + except, + id, + categoryArray, + ); + if (!Helplist) { + throw 'Pedidos de ajuda não encontrados no seu raio de distância'; + } + + return Helplist; + } + + async deleteHelpLogically(id) { + let help = await this.getHelpByid(id); + + help.active = false; + + await this.HelpRepository.update(help); + + const user = await this.UserService.getUser({ id: help.ownerId }); + const userCoords = { + longitude: user.location.coordinates[0], + latitude: user.location.coordinates[1], + }; + help = JSON.parse(JSON.stringify(help)); + const sendSocketMessageTo = findConnections(userCoords, help.categoryId, JSON.parse(JSON.stringify(user._id))); + sendMessage(sendSocketMessageTo, 'delete-help', id); + + return { message: `Help ${id} deleted!` }; + } + + async getHelpListByStatus({ userId, statusList, helper = false }) { + const checkHelpStatusExistence = statusList.filter((item) => !Object.values(helpStatusEnum).includes(item)); + + if (checkHelpStatusExistence.length > 0) { + throw 'Um dos status informados é ínvalido.'; } - async deleteHelpLogically(id) { - let help = await this.getHelpByid(id); + const helpList = await this.HelpRepository.getHelpListByStatus(userId, statusList, helper); - help.active = false; + return helpList; + } - await this.HelpRepository.update(help); - const user = await this.UserService.getUser({ id: help.ownerId }) - const userCoords = { - longitude: user.location.coordinates[0], - latitude: user.location.coordinates[1] - } - help = JSON.parse(JSON.stringify(help)); - const sendSocketMessageTo = findConnections(userCoords, help.categoryId, JSON.parse(JSON.stringify(user._id))) - sendMessage(sendSocketMessageTo, 'delete-help', id) + async chooseHelper(data) { + const { idHelper } = data; + const help = await this.getHelpByid(data.idHelp); + const { ownerId } = help; + const helper = await this.UserService.getUser({ id: idHelper }); + const owner = await this.UserService.getUser({ id: ownerId }); + if (!help) { + throw 'Ajuda não encontrada'; + } + if (help.helperId) { + throw 'Ajuda já possui ajudante'; + } + - return { message: `Help ${id} deleted!` }; + const ownerCoords = { + longitude: owner.location.coordinates[0], + latitude: owner.location.coordinates[1], + }; + const sendSocketMessageTo = findConnections( + ownerCoords, + help.categoryId, + JSON.parse(JSON.stringify(owner._id)), + ); + sendMessage(sendSocketMessageTo, 'delete-help', help._id); + + + const title = `${owner.name} aceitou sua oferta de ajuda!`; + const body = `Sua oferta para ${help.title} foi aceita`; + + const userPosition = help.possibleHelpers.indexOf(data.idHelper); + if (userPosition >= 0) { + help.helperId = data.idHelper; + help.status = 'on_going'; + help.possibleHelpers = []; + const result = await this.HelpRepository.update(help); + + const notificationHistory = { + userId: helper._id, + helpId: help._id, + title, + body, + notificationType: notificationTypesEnum.ajudaAceita, + }; + + try { + this.NotificationService.createNotification(notificationHistory); + this.NotificationMixin.sendNotification(helper.deviceId, title, body); + } catch (err) { + console.log('Não foi possível enviar a notificação!'); + } + return result; } - - async getHelpListByStatus({userId, statusList, helper = false}) { - - const checkHelpStatusExistence = statusList.filter(item => !Object.values(helpStatusEnum).includes(item)) - - if (checkHelpStatusExistence.length > 0) { - throw "Um dos status informados é ínvalido." - } - - const helpList = await this.HelpRepository.getHelpListByStatus(userId, statusList, helper); - - return helpList + throw 'Ajudante não encontrado'; + } + + async helperConfirmation(data) { + const help = await this.getHelpByid(data.helpId); + const owner = await this.UserService.getUser({ id: help.ownerId }); + const helper = await this.UserService.getUser({ id: help.helperId }); + + if (!help) { + throw 'Ajuda não encontrada'; + } else if (help.helperId !== data.helperId) { + throw 'Usuário não é o ajudante dessa ajuda'; + } else if (help.status === 'owner_finished') { + const ownerTitle = 'Pedido de ajuda finalizado!'; + const ownerBody = `Seu pedido ${help.title} foi finalizado`; + + const ownerNotificationHistory = { + userId: help.ownerId, + helpId: help._id, + title: ownerTitle, + body: ownerBody, + notificationType: notificationTypesEnum.ajudaFinalizada, + }; + + const helperTitle = 'Oferta de ajuda finalizada!'; + const helperBody = `Sua oferta da ajuda ${help.title} foi finalizada`; + const helperNotificationHistory = { + userId: help.helperId, + helpId: help._id, + title: helperTitle, + body: helperBody, + notificationType: notificationTypesEnum.ajudaFinalizada, + }; + + try { + this.NotificationMixin.sendNotification(owner.deviceId, ownerTitle, ownerBody); + this.NotificationService.createNotification(ownerNotificationHistory); + this.NotificationMixin.sendNotification(helper.deviceId, helperTitle, helperBody); + this.NotificationService.createNotification(helperNotificationHistory); + } catch (err) { + console.log('Não foi possível enviar a notificação!'); + } + + help.status = 'finished'; + } else if (help.status === 'helper_finished') { + throw 'Usuário já confirmou a finalização da ajuda'; + } else if (help.status === 'finished') { + throw 'Ajuda já foi finalizada'; + } else { + help.status = 'helper_finished'; } + const result = await this.HelpRepository.update(help); + + return result; + } + + async ownerConfirmation(data) { + const help = await this.getHelpByid(data.helpId); + const owner = await this.UserService.getUser({ id: help.ownerId }); + const helper = await this.UserService.getUser({ id: help.helperId }); + + if (!help) { + throw 'Ajuda não encontrada'; + } else if (help.ownerId !== data.ownerId) { + throw 'Usuário não é o dono da ajuda'; + } else if (help.status === 'helper_finished') { + const ownerTitle = 'Pedido de ajuda finalizado!'; + const ownerBody = `Seu pedido ${help.title} foi finalizado`; + + const ownerNotificationHistory = { + userId: help.ownerId, + helpId: help._id, + title: ownerTitle, + body: ownerBody, + notificationType: notificationTypesEnum.ajudaFinalizada, + }; + + const helperTitle = 'Oferta de ajuda finalizada!'; + const helperBody = `Sua oferta da ajuda ${help.title} foi finalizada`; + const helperNotificationHistory = { + userId: help.helperId, + helpId: help._id, + title: helperTitle, + body: helperBody, + notificationType: notificationTypesEnum.ajudaFinalizada, + }; + + try { + this.NotificationMixin.sendNotification(owner.deviceId, ownerTitle, ownerBody); + this.NotificationService.createNotification(ownerNotificationHistory); + this.NotificationMixin.sendNotification(helper.deviceId, helperTitle, helperBody); + this.NotificationService.createNotification(helperNotificationHistory); + } catch (err) { + console.log('Não foi possível enviar a notificação!'); + } + + help.status = 'finished'; + } else if (help.status === 'owner_finished') { + throw 'Usuário já confirmou a finalização da ajuda'; + } else if (help.status === 'finished') { + throw 'Essa ajuda já foi finalizada'; + } else { + help.status = 'owner_finished'; + } + + const result = await this.HelpRepository.update(help); + return result; + } - async chooseHelper(data) { - const idHelper = data.idHelper; - const help = await this.getHelpByid(data.idHelp); - const ownerId = help.ownerId; - const helper = await this.UserService.getUser({ id: idHelper }); - const owner = await this.UserService.getUser({ id: ownerId }); - if (!help) { - throw "Ajuda não encontrada"; - } - if (help.helperId) { - throw "Ajuda já possui ajudante"; - } - - - const ownerCoords = { - longitude: owner.location.coordinates[0], - latitude: owner.location.coordinates[1], - }; - const sendSocketMessageTo = findConnections( - ownerCoords, - help.categoryId, - JSON.parse(JSON.stringify(owner._id)) - ); - sendMessage(sendSocketMessageTo, 'delete-help', help._id) - - - - const title = owner.name + " aceitou sua oferta de ajuda!"; - const body = "Sua oferta para " + help.title + " foi aceita"; - - const userPosition = help.possibleHelpers.indexOf(data.idHelper); - if (userPosition >= 0) { - help.helperId = data.idHelper; - help.status = "on_going"; - help.possibleHelpers = []; - const result = await this.HelpRepository.update(help); - - const notificationHistory = { - userId: helper._id, - helpId: help._id, - title: title, - body: body, - notificationType: notificationTypesEnum.ajudaAceita, - }; - - try { - this.NotificationService.createNotification(notificationHistory); - this.NotificationMixin.sendNotification(helper.deviceId, title, body); - } catch (err) { - console.log("Não foi possível enviar a notificação!"); - } - return result; - } - throw "Ajudante não encontrado"; + async addPossibleHelpers(id, idHelper) { + const help = await this.getHelpByid(id); + const owner = await this.UserService.getUser({ id: help.ownerId }); + if (!help) { + throw 'Ajuda não encontrada'; } - async helperConfirmation(data) { - const help = await this.getHelpByid(data.helpId); - const owner = await this.UserService.getUser({ id: help.ownerId }); - const helper = await this.UserService.getUser({ id: help.helperId }); - - if (!help) { - throw "Ajuda não encontrada"; - } - else if (help.helperId != data.helperId) { - throw "Usuário não é o ajudante dessa ajuda"; - } - else if (help.status == "owner_finished") { - const ownerTitle = "Pedido de ajuda finalizado!"; - const ownerBody = "Seu pedido " + help.title + " foi finalizado"; - - const ownerNotificationHistory = { - userId: help.ownerId, - helpId: help._id, - title: ownerTitle, - body: ownerBody, - notificationType: notificationTypesEnum.ajudaFinalizada, - }; - - const helperTitle = "Oferta de ajuda finalizada!"; - const helperBody = "Sua oferta da ajuda " + help.title + " foi finalizada"; - const helperNotificationHistory = { - userId: help.helperId, - helpId: help._id, - title: helperTitle, - body: helperBody, - notificationType: notificationTypesEnum.ajudaFinalizada, - }; - - try { - this.NotificationMixin.sendNotification(owner.deviceId, ownerTitle, ownerBody); - this.NotificationService.createNotification(ownerNotificationHistory); - this.NotificationMixin.sendNotification(helper.deviceId, helperTitle, helperBody); - this.NotificationService.createNotification(helperNotificationHistory); - } catch (err) { - console.log("Não foi possível enviar a notificação!"); - } - - help.status = "finished"; - } - else if (help.status == "helper_finished") { - throw "Usuário já confirmou a finalização da ajuda"; - } - else if (help.status == "finished") { - throw "Ajuda já foi finalizada"; - } - else { - help.status = "helper_finished"; - } - - const result = await this.HelpRepository.update(help); - - return result; + if (idHelper === help.ownerId) { + throw 'Você não pode ser ajudante de sua própria ajuda'; + } + if (help.helperId) { + throw 'Ajuda já possui ajudante'; } - async ownerConfirmation(data) { - const help = await this.getHelpByid(data.helpId); - const owner = await this.UserService.getUser({ id: help.ownerId }); - const helper = await this.UserService.getUser({ id: help.helperId }); - - if (!help) { - throw "Ajuda não encontrada"; - } else if (help.ownerId != data.ownerId) { - throw "Usuário não é o dono da ajuda"; - } else if (help.status == "helper_finished") { - const ownerTitle = "Pedido de ajuda finalizado!"; - const ownerBody = "Seu pedido " + help.title + " foi finalizado"; - - const ownerNotificationHistory = { - userId: help.ownerId, - helpId: help._id, - title: ownerTitle, - body: ownerBody, - notificationType: notificationTypesEnum.ajudaFinalizada, - }; - - const helperTitle = "Oferta de ajuda finalizada!"; - const helperBody = "Sua oferta da ajuda " + help.title + " foi finalizada"; - const helperNotificationHistory = { - userId: help.helperId, - helpId: help._id, - title: helperTitle, - body: helperBody, - notificationType: notificationTypesEnum.ajudaFinalizada, - }; - - try { - this.NotificationMixin.sendNotification(owner.deviceId, ownerTitle, ownerBody); - this.NotificationService.createNotification(ownerNotificationHistory); - this.NotificationMixin.sendNotification(helper.deviceId, helperTitle, helperBody); - this.NotificationService.createNotification(helperNotificationHistory); - } catch (err) { - console.log ("Não foi possível enviar a notificação!"); - } - - help.status = "finished"; - - } else if (help.status == "owner_finished") { - throw "Usuário já confirmou a finalização da ajuda"; - } else if (help.status == "finished") { - throw "Essa ajuda já foi finalizada"; - } else { - help.status = "owner_finished"; - } - - const result = await this.HelpRepository.update(help); - return result; + const helper = await this.UserService.getUser({ id: idHelper }); + const userPosition = help.possibleHelpers.indexOf(idHelper); + + if (userPosition > -1) { + throw 'Usuário já é um possível ajudante'; } - async addPossibleHelpers(id, idHelper) { - const help = await this.getHelpByid(id); - const owner = await this.UserService.getUser({ id: help.ownerId }); - if (!help) { - throw "Ajuda não encontrada"; - } - - if (idHelper == help.ownerId) { - throw "Você não pode ser ajudante de sua própria ajuda"; - } - if (help.helperId) { - throw "Ajuda já possui ajudante"; - } - - const helper = await this.UserService.getUser({ id: idHelper }); - const userPosition = help.possibleHelpers.indexOf(idHelper); - - if (userPosition > -1) { - throw "Usuário já é um possível ajudante"; - } - - help.possibleHelpers.push(idHelper); - - const result = await this.HelpRepository.update(help); - - const title = helper.name + " quer te ajudar!"; - const body = "Seu pedido " + help.title + " recebeu uma oferta de ajuda"; - - const notificationHistory = { - userId: help.ownerId, - helpId: help._id, - title: title, - body: body, - notificationType: notificationTypesEnum.ajudaRecebida, - }; - - try { - this.NotificationMixin.sendNotification(owner.deviceId, title, body); - this.NotificationService.createNotification(notificationHistory); - } catch (err) { - console.log("Não foi possível enviar a notificação!"); - } - - return result; + help.possibleHelpers.push(idHelper); + + const result = await this.HelpRepository.update(help); + + const title = `${helper.name} quer te ajudar!`; + const body = `Seu pedido ${help.title} recebeu uma oferta de ajuda`; + + const notificationHistory = { + userId: help.ownerId, + helpId: help._id, + title, + body, + notificationType: notificationTypesEnum.ajudaRecebida, + }; + + try { + this.NotificationMixin.sendNotification(owner.deviceId, title, body); + this.NotificationService.createNotification(notificationHistory); + } catch (err) { + console.log('Não foi possível enviar a notificação!'); } - async getListToDelete() { - const Helplist = await this.HelpRepository.listToExpire(); - if (!Helplist) { - throw new Error("Pedidos de ajuda não encontrados"); - } + return result; + } - return Helplist; + async getListToDelete() { + const Helplist = await this.HelpRepository.listToExpire(); + if (!Helplist) { + throw new Error('Pedidos de ajuda não encontrados'); } + + return Helplist; + } } module.exports = HelpService; diff --git a/src/services/NotificationService.js b/src/services/NotificationService.js index b03cded8..f8bccb56 100644 --- a/src/services/NotificationService.js +++ b/src/services/NotificationService.js @@ -1,22 +1,21 @@ const NotificationRepository = require('../repository/NotificationRepository'); class NotificationService { - constructor() { - this.notificationRepository = new NotificationRepository(); - } + constructor() { + this.notificationRepository = new NotificationRepository(); + } - async getUserNotificationsById(id) { - const userNotifications = await this.notificationRepository.getUserNotificationsById(id); + async getUserNotificationsById(id) { + const userNotifications = await this.notificationRepository.getUserNotificationsById(id); - return userNotifications; - } + return userNotifications; + } - async createNotification(notification) { - const notificationCreated = await this.notificationRepository.create(notification); - - return notificationCreated; - } + async createNotification(notification) { + const notificationCreated = await this.notificationRepository.create(notification); + return notificationCreated; + } } module.exports = NotificationService; diff --git a/src/services/UserService.js b/src/services/UserService.js index 31326d7e..6f71838b 100644 --- a/src/services/UserService.js +++ b/src/services/UserService.js @@ -1,5 +1,5 @@ -const UserRepository = require("../repository/UserRepository"); -const firebase = require("../config/authFirebase"); +const UserRepository = require('../repository/UserRepository'); +const firebase = require('../config/authFirebase'); class UserService { constructor() { @@ -8,11 +8,11 @@ class UserService { async createUser(data) { if (data.password.length < 8) { - throw "Senha inválida"; + throw 'Senha inválida'; } if (data.cpf.length >= 11) { - data.cpf = data.cpf.replace(/[-.]/g, ""); + data.cpf = data.cpf.replace(/[-.]/g, ''); } data.email = data.email.toLowerCase(); try { @@ -41,7 +41,7 @@ class UserService { async getUser({ id = undefined, email = undefined }) { if (!id && !email) { - throw { id: "Nenhum identificador encontrado" }; + throw { id: 'Nenhum identificador encontrado' }; } let user; @@ -51,7 +51,7 @@ class UserService { user = await this.userRepository.getUserByEmail(email); } if (!user) { - throw "Usuário não encontrado"; + throw 'Usuário não encontrado'; } return user; @@ -68,7 +68,7 @@ class UserService { const user = await this.getUser({ email }); if (!user) { - throw "Usuário não encontrado"; + throw 'Usuário não encontrado'; } user.photo = photo || user.photo; @@ -82,11 +82,13 @@ class UserService { return result; } - async editUserAddressById({ email, cep, number, city, state, complement }) { + async editUserAddressById({ + email, cep, number, city, state, complement, + }) { const user = await this.getUser({ email }); if (!user) { - throw "Usuário não encontrado"; + throw 'Usuário não encontrado'; } const address = { @@ -108,7 +110,7 @@ class UserService { const user = await this.getUser({ email }); if (!user) { - throw "Usuário não encontrado"; + throw 'Usuário não encontrado'; } if (longitude || latitude) { @@ -128,15 +130,15 @@ class UserService { await this.userRepository.update(user); - return { message: `User ${id} deleted!` }; + return { message: `User ${user._id} deleted!` }; } async removeUser(email) { try { const user = await this.getUser({ email }); await this.userRepository.removeUser({ id: user._id, email }); - } catch { - return; + } catch (err) { + console.log(err); } } diff --git a/src/utils/Notification.js b/src/utils/Notification.js index cfb3b4c7..467b6af9 100644 --- a/src/utils/Notification.js +++ b/src/utils/Notification.js @@ -1,57 +1,52 @@ -const { Expo } = require('expo-server-sdk') +const { Expo } = require('expo-server-sdk'); const notify = async (messages) => { - let expo = new Expo(); - let chunks = expo.chunkPushNotifications(messages); - let tickets = []; - (async () => { - - for (let chunk of chunks) { - try { - let ticketChunk = await expo.sendPushNotificationsAsync(chunk); - tickets.push(...ticketChunk); - - } catch (error) { - console.error(error); - } - } - })(); + const expo = new Expo(); + const chunks = expo.chunkPushNotifications(messages); + const tickets = []; + (async () => { + for (const chunk of chunks) { + try { + const ticketChunk = await expo.sendPushNotificationsAsync(chunk); + tickets.push(...ticketChunk); + } catch (error) { + console.error(error); + } + } + })(); - - let receiptIds = []; - for (let ticket of tickets) { - - if (ticket.id) { - receiptIds.push(ticket.id); - } + + const receiptIds = []; + for (const ticket of tickets) { + if (ticket.id) { + receiptIds.push(ticket.id); } + } - let receiptIdChunks = expo.chunkPushNotificationReceiptIds(receiptIds); - (async () => { - - for (let chunk of receiptIdChunks) { - try { - let receipts = await expo.getPushNotificationReceiptsAsync(chunk); + const receiptIdChunks = expo.chunkPushNotificationReceiptIds(receiptIds); + (async () => { + for (const chunk of receiptIdChunks) { + try { + const receipts = await expo.getPushNotificationReceiptsAsync(chunk); - for (let receiptId in receipts) { - let { status, message, details } = receipts[receiptId]; - if (status === 'ok') { - continue; - } else if (status === 'error') { - console.error( - `There was an error sending a notification: ${message}` - ); - if (details && details.error) { - - console.error(`The error code is ${details.error}`); - } - } - } - } catch (error) { - console.error(error); + for (const receiptId in receipts) { + const { status, message, details } = receipts[receiptId]; + if (status === 'ok') { + continue; + } else if (status === 'error') { + console.error( + `There was an error sending a notification: ${message}`, + ); + if (details && details.error) { + console.error(`The error code is ${details.error}`); } + } } - })() -} + } catch (error) { + console.error(error); + } + } + })(); +}; -module.exports = notify; \ No newline at end of file +module.exports = notify; diff --git a/src/utils/NotificationMixin.js b/src/utils/NotificationMixin.js index 7247e8bd..3df40bd4 100644 --- a/src/utils/NotificationMixin.js +++ b/src/utils/NotificationMixin.js @@ -1,30 +1,28 @@ -const notify = require("./Notification"); +const notify = require('./Notification'); class NotificationService { - constructor() { } - async sendNotification(deviceId = '', title = '', body = '') { - let messages = [] + const messages = []; const message = { to: deviceId, sound: 'default', - title: title, - body: body, - _displayInForeground: true - } - if(!message.to){ - console.log("O usuário não possui deviceId") - return + title, + body, + _displayInForeground: true, + }; + if (!message.to) { + console.log('O usuário não possui deviceId'); + return; } - messages.push(message) - + messages.push(message); + try { - notify(messages) - } catch(err) { + notify(messages); + } catch (err) { + console.log(err); } } - } -module.exports = NotificationService \ No newline at end of file +module.exports = NotificationService; diff --git a/src/utils/enums/helpStatusEnum.js b/src/utils/enums/helpStatusEnum.js index fa20c66c..4d550478 100644 --- a/src/utils/enums/helpStatusEnum.js +++ b/src/utils/enums/helpStatusEnum.js @@ -1,8 +1,8 @@ const helpStatusEnum = { - WAITING: "waiting", - ON_GOING: "on_going", - FINISHED: "finished", - OWNER_FINISHED: "owner_finished", - HELPER_FINISHED: "helper_finished" -} -module.exports = helpStatusEnum \ No newline at end of file + WAITING: 'waiting', + ON_GOING: 'on_going', + FINISHED: 'finished', + OWNER_FINISHED: 'owner_finished', + HELPER_FINISHED: 'helper_finished', +}; +module.exports = helpStatusEnum; diff --git a/src/utils/geolocation/calculateDistance.js b/src/utils/geolocation/calculateDistance.js index 448188f2..456edf15 100644 --- a/src/utils/geolocation/calculateDistance.js +++ b/src/utils/geolocation/calculateDistance.js @@ -11,29 +11,28 @@ function calculateDistance(centerCoordinates, pointCoordinates) { const dLat = deg2rad(lat2 - lat1); const dLon = deg2rad(lon2 - lon1); - const a = - Math.sin(dLat / 2) * Math.sin(dLat / 2) + - Math.cos(deg2rad(lat1)) * - Math.cos(deg2rad(lat2)) * - Math.sin(dLon / 2) * - Math.sin(dLon / 2); + const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + + Math.cos(deg2rad(lat1)) + * Math.cos(deg2rad(lat2)) + * Math.sin(dLon / 2) + * Math.sin(dLon / 2); const center = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - let distance = radius * center; + const distance = radius * center; return distance; } function convertDistance(distance) { return distance > 1 - ? `${distance.toFixed(2)} km` - : `${(distance * 1000).toFixed(0)} m`; + ? `${distance.toFixed(2)} km` + : `${(distance * 1000).toFixed(0)} m`; } function getDistance(centerCoordinates, pointCoordinates) { - let distance = calculateDistance(centerCoordinates, pointCoordinates) + let distance = calculateDistance(centerCoordinates, pointCoordinates); - distance = convertDistance(distance) + distance = convertDistance(distance); return distance; } @@ -41,5 +40,5 @@ function getDistance(centerCoordinates, pointCoordinates) { module.exports = { calculateDistance, getDistance, - convertDistance + convertDistance, }; diff --git a/src/utils/schedule.js b/src/utils/schedule.js index c3051ff6..48e28ed8 100644 --- a/src/utils/schedule.js +++ b/src/utils/schedule.js @@ -1,64 +1,65 @@ -const HelpService = require('../services/HelpService') -const UserService = require('../services/UserService') +const nodeSchedule = require('node-schedule'); +const HelpService = require('../services/HelpService'); +const UserService = require('../services/UserService'); const NotificationService = require('../services/NotificationService'); -const notify = require('./Notification') -const nodeSchedule = require('node-schedule') -const { notificationTypesEnum } = require('../models/Notification') +const notify = require('./Notification'); +const { notificationTypesEnum } = require('../models/Notification'); function dailySchedule() { - const notificationService = new NotificationService(); + const notificationService = new NotificationService(); - nodeSchedule.scheduleJob('* * 08,18 * * *', async () => { - const helpService = new HelpService(); - const userService = new UserService(); + nodeSchedule.scheduleJob('* * 08,18 * * *', async () => { + const helpService = new HelpService(); + const userService = new UserService(); - const helpsToDelete = await helpService.getListToDelete() - if(!helpsToDelete.length){ - return - } + const helpsToDelete = await helpService.getListToDelete(); + if (!helpsToDelete.length) { + return; + } - let messages = [] - let notifications = [] - for (let help of helpsToDelete) { - let user = userService.getUser(help.ownerId) - let message = { - to: user.deviceId, - sound: 'default', - title: 'Pedido de ajuda expirado!', - body: 'Seu pedido ' + help.title + ' expirou', - data: { Pedido: help.description } - } + const messages = []; + const notifications = []; + for (const help of helpsToDelete) { + const user = userService.getUser(help.ownerId); + const message = { + to: user.deviceId, + sound: 'default', + title: 'Pedido de ajuda expirado!', + body: `Seu pedido ${help.title} expirou`, + data: { Pedido: help.description }, + }; - const notificationHistory = { - userId: help.ownerId, - helpId: help._id, - title: message.title, - body: message.body, - notificationType: notificationTypesEnum.ajudaExpirada, - } - - notifications.push(notificationHistory); - messages.push(message) - } + const notificationHistory = { + userId: help.ownerId, + helpId: help._id, + title: message.title, + body: message.body, + notificationType: notificationTypesEnum.ajudaExpirada, + }; - let iterator = 0; + notifications.push(notificationHistory); + messages.push(message); + } - try { - notify(messages) - } catch (err) { - console.log(err) - } - return await Promise.all(helpsToDelete.map(async (help) => { - try { - messageDeleted = await helpService.deleteHelpLogically(help.id); - await notificationService.createNotification(notifications[iterator++]); + let iterator = 0; - return messageDeleted; - } catch (err) { - throw err - } - })) - }) + try { + notify(messages); + } catch (err) { + console.log(err); + } + return await Promise.all(helpsToDelete.map(async (help) => { + try { + messageDeleted = await helpService.deleteHelpLogically(help.id); + await notificationService.createNotification(notifications[iterator]); + iterator += 1; + + return messageDeleted; + } catch (err) { + throw err; + } + })); + }); } -module.exports = dailySchedule \ No newline at end of file +module.exports = dailySchedule; diff --git a/src/utils/seed/CategorySeed.js b/src/utils/seed/CategorySeed.js index 4843caac..c04e37a6 100644 --- a/src/utils/seed/CategorySeed.js +++ b/src/utils/seed/CategorySeed.js @@ -1,70 +1,70 @@ const Category = require('../../models/Category'); const mapCategories = [ - { - name: 'Higiene Pessoal', - description: 'Todos precisam de itens essenciais, como itens de higiene pessoal como papel higienico, lenços umidecidos, fraldas, pasta de dente, entre outros, ajude como pode quem mais precisa! Seja a diferença na vida de alguém hoje!', - }, - { - name: 'Apoio Social', - description: 'Todo apoio é bem-vindo, seja este afetivo, emocional e/ou motivacional! Você pode colaborar contando uma história, cantando uma música, recitando um poema, apresentando uma peça teatral, tocando um instrumento musical, ou apenas conversando. Use a sua criatividade! Muitos precisam do seu apoio nesse momento! Sua colaboração faz muita diferença! Participe!', - }, - { - name: 'Itens de Proteção', - description: 'Em momentos difíceis como este, precisamos nos proteger e proteger nossos parentes e entes queridos, ajude pessoas doando ou comprando para elas itens como máscaras, alcool gel, luvas, entre outros. Vamos todos nos ajudar!', - }, - { - name: 'Apoio Psicológico', - description: 'Pessoas em estado de isolamento tendem a se sentir mais tristes ou ansiosas do que o normal. Ajude uma pessoa que está passando por esse momento sozinho.', - }, - { - name: 'Pequenos Serviços', - description: 'As pequenas coisas podem fazer diferença. Colabore ajudando em um pequeno conserto ou até mesmo trocando uma lâmpada. Toda forma de ajuda é necessária, para aqueles que mais precisam!', - }, - { - name: 'Suprimentos Básicos', - description: 'Todo mundo precisa do básico para viver, seja com um pacote de arroz, um quilo de feijão, ou até mesmo uma duzia de ovos. Você pode ajudar quem mais precisa ou não tem como ir ao mercado! Faça a diferença!', - }, - { - name: 'Transporte de Emergência', - description: 'As vezes, um pequeno gesto pode salvar uma vida, alguém pode estar precisando de uma carona para o hospital. Ajude, mas proteja-se! Você pode ser o motivo de agradecimento de alguém.', - }, - { - name: 'Apoio Físico', - description: 'Não podemos ficar parados, sedentarismo pode atrair diversas doenças. Ajude quem mais precisa com alguma série de exercícios físicos, ou até mesmo em uma sessão de alongamentos. Vamos nos movimentar!', - }, + { + name: 'Higiene Pessoal', + description: 'Todos precisam de itens essenciais, como itens de higiene pessoal como papel higienico,lenços umidecidos, fraldas, pasta de dente, entre outros, ajude como pode quem mais precisa! Seja a diferença na vida de alguém hoje!', + }, + { + name: 'Apoio Social', + description: 'Todo apoio é bem-vindo, seja este afetivo, emocional e/ou motivacional! Você pode colaborar contando uma história, cantando uma música, recitando um poema, apresentando uma peça teatral, tocando um instrumento musical, ou apenas conversando. Use a sua criatividade! Muitos precisam do seu apoio nesse momento! Sua colaboração faz muita diferença! Participe!', + }, + { + name: 'Itens de Proteção', + description: 'Em momentos difíceis como este, precisamos nos proteger e proteger nossos parentes e entes queridos, ajude pessoas doando ou comprando para elas itens como máscaras, alcool gel, luvas, entre outros. Vamos todos nos ajudar!', + }, + { + name: 'Apoio Psicológico', + description: 'Pessoas em estado de isolamento tendem a se sentir mais tristes ou ansiosas do que o normal. Ajude uma pessoa que está passando por esse momento sozinho.', + }, + { + name: 'Pequenos Serviços', + description: 'As pequenas coisas podem fazer diferença. Colabore ajudando em um pequeno conserto ou até mesmo trocando uma lâmpada. Toda forma de ajuda é necessária, para aqueles que mais precisam!', + }, + { + name: 'Suprimentos Básicos', + description: 'Todo mundo precisa do básico para viver, seja com um pacote de arroz, um quilo de feijão, ou até mesmo uma duzia de ovos. Você pode ajudar quem mais precisa ou não tem como ir ao mercado! Faça a diferença!', + }, + { + name: 'Transporte de Emergência', + description: 'As vezes, um pequeno gesto pode salvar uma vida, alguém pode estar precisando de uma carona para o hospital. Ajude, mas proteja-se! Você pode ser o motivo de agradecimento de alguém.', + }, + { + name: 'Apoio Físico', + description: 'Não podemos ficar parados, sedentarismo pode atrair diversas doenças. Ajude quem mais precisa com alguma série de exercícios físicos, ou até mesmo em uma sessão de alongamentos. Vamos nos movimentar!', + }, ]; const seedCategory = async () => { - try { - const categoryCollection = await Category.find(); + try { + const categoryCollection = await Category.find(); - // this condition avoid populate duplicate users - if (categoryCollection.length > 0) { - return; - } + // this condition avoid populate duplicate users + if (categoryCollection.length > 0) { + return; + } - const categories = []; - const quantity = mapCategories.length; - for (let i = 0; i < quantity; i++) { - categories.push( - new Category({ - name: mapCategories[i].name, - description: mapCategories[i].description, - }), - ); - } + const categories = []; + const quantity = mapCategories.length; + for (let i = 0; i < quantity; i += 1) { + categories.push( + new Category({ + name: mapCategories[i].name, + description: mapCategories[i].description, + }), + ); + } - await Category.deleteMany({}); + await Category.deleteMany({}); - categories.forEach((category) => { - Category.create(category); - }); - console.log('Categorias populadas com sucesso!'); - } catch (error) { - console.log('Não foi possível popular as categorias na base de dados!'); - console.log(error); - } + categories.forEach((category) => { + Category.create(category); + }); + console.log('Categorias populadas com sucesso!'); + } catch (error) { + console.log('Não foi possível popular as categorias na base de dados!'); + console.log(error); + } }; module.exports = seedCategory; diff --git a/src/utils/seed/HelpSeed.js b/src/utils/seed/HelpSeed.js index 74adeaf4..fc201642 100644 --- a/src/utils/seed/HelpSeed.js +++ b/src/utils/seed/HelpSeed.js @@ -1,16 +1,15 @@ -const lodash = require("lodash"); -const faker = require("faker/locale/pt_BR"); - -const Category = require("../../models/Category"); -const Help = require("../../models/Help"); -const User = require("../../models/User"); +const lodash = require('lodash'); +const faker = require('faker/locale/pt_BR'); +const Category = require('../../models/Category'); +const Help = require('../../models/Help'); +const User = require('../../models/User'); const status = [ - "waiting", - "on_going", - "finished", - "helper_finished", - "owner_finished", + 'waiting', + 'on_going', + 'finished', + 'helper_finished', + 'owner_finished', ]; const seedHelp = async () => { @@ -26,13 +25,13 @@ const seedHelp = async () => { const quantity = 100; const helps = []; - for (let i = 0; i < quantity; i++) { - const sampleStatus = await lodash.sample(status); - const sampleCategory = await lodash.sample(categoryCollection); - const sampleUsers = await lodash.sampleSize(userCollection, 2); - const samplePossibleHelpers = await lodash.sampleSize( + for (let i = 0; i < quantity; i += 1) { + const sampleStatus = lodash.sample(status); + const sampleCategory = lodash.sample(categoryCollection); + const sampleUsers = lodash.sampleSize(userCollection, 2); + const samplePossibleHelpers = lodash.sampleSize( userCollection, - faker.random.number(5) + faker.random.number(5), ); const samplePossibleHelpsID = []; samplePossibleHelpers.forEach((item) => { @@ -48,7 +47,7 @@ const seedHelp = async () => { categoryId: sampleCategory._id, ownerId: sampleUsers[0]._id, finishedDate: faker.date.future(), - }) + }), ); } @@ -58,9 +57,9 @@ const seedHelp = async () => { Help.create(help); }); - console.log("Ajudas populadas com sucesso!"); + console.log('Ajudas populadas com sucesso!'); } catch (error) { - console.log("Não foi possível popular as ajudas na base de dados!"); + console.log('Não foi possível popular as ajudas na base de dados!'); console.log(error); } }; diff --git a/src/utils/seed/NotificationSeed.js b/src/utils/seed/NotificationSeed.js index 755aa0b3..2b6d6663 100644 --- a/src/utils/seed/NotificationSeed.js +++ b/src/utils/seed/NotificationSeed.js @@ -1,51 +1,49 @@ const lodash = require('lodash'); const faker = require('faker/locale/pt_BR'); - const Help = require('../../models/Help'); const User = require('../../models/User'); const { Notification } = require('../../models/Notification'); -const notificationTypes = ['ajudaRecebida', 'ajudaAceita', 'ajudaFinalizada', 'ajudaExpirada', 'outros']; +const notificationTypes = ['ajudaRecebida', 'ajudaAceita', 'ajudaFinalizada', 'ajudaExpirada', 'outros']; const notificationSeed = async () => { - try { - const userCollection = await User.find(); - const helpCollection = await Help.find(); - const notificationCollection = await Notification.find(); - - // this condition avoid populate duplicate users - if (notificationCollection.length > 0) { - return; - } - - const quantity = 500; - const notifications = []; - for(let i = 0; i < quantity; i++) { - const sampleUser = await lodash.sample(userCollection); - const sampleHelp = await lodash.sample(helpCollection); - const sampleNotificationType = await lodash.sample( - notificationTypes); - - notifications.push({ - userId: sampleUser._id, - helpId: sampleHelp._id, - title: faker.lorem.words(5), - body: faker.lorem.paragraph(), - notificationType: sampleNotificationType - }); - } - - await Notification.deleteMany({}); - - notifications.forEach((notification) => { - Notification.create(notification); - }) - - console.log('Notificações populadas com sucesso!'); - } catch (error) { - console.log('Não foi possível popular as notificações na base de dados!'); - console.log(error); + try { + const userCollection = await User.find(); + const helpCollection = await Help.find(); + const notificationCollection = await Notification.find(); + + // this condition avoid populate duplicate users + if (notificationCollection.length > 0) { + return; + } + + const quantity = 500; + const notifications = []; + for (let i = 0; i < quantity; i += 1) { + const sampleUser = lodash.sample(userCollection); + const sampleHelp = lodash.sample(helpCollection); + const sampleNotificationType = lodash.sample(notificationTypes); + + notifications.push({ + userId: sampleUser._id, + helpId: sampleHelp._id, + title: faker.lorem.words(5), + body: faker.lorem.paragraph(), + notificationType: sampleNotificationType, + }); } + + await Notification.deleteMany({}); + + notifications.forEach((notification) => { + Notification.create(notification); + }); + + console.log('Notificações populadas com sucesso!'); + } catch (error) { + console.log('Não foi possível popular as notificações na base de dados!'); + console.log(error); + } }; module.exports = notificationSeed; diff --git a/src/utils/seed/UserSeed.js b/src/utils/seed/UserSeed.js index 3324826a..be045b3c 100644 --- a/src/utils/seed/UserSeed.js +++ b/src/utils/seed/UserSeed.js @@ -1,63 +1,64 @@ -const User = require('../../models/User'); const faker = require('faker/locale/pt_BR'); const lodash = require('lodash'); const { cpf } = require('cpf-cnpj-validator'); -const diseases = ['dc','hiv','diab','hiperT','doenCardio']; -var latitude = process.env.LATITUDE_ENV || -15.824544; -var longitude = process.env.LONGITUDE_ENV || -48.060878; +const User = require('../../models/User'); + +const diseases = ['dc', 'hiv', 'diab', 'hiperT', 'doenCardio']; +let latitude = process.env.LATITUDE_ENV || -15.824544; +let longitude = process.env.LONGITUDE_ENV || -48.060878; const seedUser = async () => { - try { - const userCollection = await User.find(); - - // this condition avoid populate duplicate users - if (userCollection.length > 0) { - return; - } + try { + const userCollection = await User.find(); - const users = []; - const quantity = 100; - for (let i = 0; i < quantity; i++) { - const sampleRiskGroup = await lodash.sampleSize(diseases, faker.random.number(5)); - longitude = Number(longitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); - latitude = Number(latitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); - users.push( - new User({ - name: faker.name.findName(), - birthday: Date.parse(faker.date.between('1940-01-01', '2020-01-01')), - cpf: cpf.generate(), - email: faker.internet.email(), - photo: faker.image.avatar(), - address: { - cep: faker.address.zipCode(), - number: faker.random.number(), - city: faker.address.city(), - state: faker.address.state(), - complement: faker.lorem.lines(1), - }, - location: { - type: 'Point', - coordinates: [ - longitude, - latitude - ], - }, - riskGroup: sampleRiskGroup, - ismentalHealthProfessional: faker.random.boolean(), - phone: faker.phone.phoneNumber('+55######-####'), - active: true - }), - ); - } - await User.deleteMany({}); - - users.forEach((user) => { - User.create(user); - }); - console.log('Usuários populados com sucesso!'); - } catch (error) { - console.log('Não foi possível popular os usuáriios na base de dados!'); - console.log(error); + // this condition avoid populate duplicate users + if (userCollection.length > 0) { + return; } + + const users = []; + const quantity = 100; + for (let i = 0; i < quantity; i += 1) { + const sampleRiskGroup = lodash.sampleSize(diseases, faker.random.number(5)); + longitude = Number(longitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); + latitude = Number(latitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); + users.push( + new User({ + name: faker.name.findName(), + birthday: Date.parse(faker.date.between('1940-01-01', '2020-01-01')), + cpf: cpf.generate(), + email: faker.internet.email(), + photo: faker.image.avatar(), + address: { + cep: faker.address.zipCode(), + number: faker.random.number(), + city: faker.address.city(), + state: faker.address.state(), + complement: faker.lorem.lines(1), + }, + location: { + type: 'Point', + coordinates: [ + longitude, + latitude, + ], + }, + riskGroup: sampleRiskGroup, + ismentalHealthProfessional: faker.random.boolean(), + phone: faker.phone.phoneNumber('+55######-####'), + active: true, + }), + ); + } + await User.deleteMany({}); + + users.forEach((user) => { + User.create(user); + }); + console.log('Usuários populados com sucesso!'); + } catch (error) { + console.log('Não foi possível popular os usuáriios na base de dados!'); + console.log(error); + } }; -module.exports = seedUser; \ No newline at end of file +module.exports = seedUser; diff --git a/src/validation/middlewares/authFirebase.js b/src/validation/middlewares/authFirebase.js index c80ea852..5c8bb63d 100644 --- a/src/validation/middlewares/authFirebase.js +++ b/src/validation/middlewares/authFirebase.js @@ -1,22 +1,20 @@ const admin = require('../../config/authFirebase'); -const isAuthenticated = async (req, res, next) => { - - if ( - req.headers.authorization && - req.headers.authorization.split(' ')[0] === 'Bearer' - ) { - const token = req.headers.authorization.split(' ')[1]; +const isAuthenticated = async (req, res, next) => { + if (req.headers.authorization + && req.headers.authorization.split(' ')[0] === 'Bearer' + ) { + const token = req.headers.authorization.split(' ')[1]; - try { - const idToken = await admin.auth().verifyIdToken(token) - req.decodedToken = idToken - return next(); - } catch { - return res.status(401).json({ error: 'Usuário não autorizado' }); - } + try { + const idToken = await admin.auth().verifyIdToken(token); + req.decodedToken = idToken; + return next(); + } catch (err) { + return res.status(401).json({ error: 'Usuário não autorizado' }); } - return res.status(403).json({ error: 'Usuário não está autenticado' }); + } + return res.status(403).json({ error: 'Usuário não está autenticado' }); }; -module.exports = isAuthenticated; \ No newline at end of file +module.exports = isAuthenticated; diff --git a/websocket.js b/websocket.js index 160cfa1d..a8b38706 100644 --- a/websocket.js +++ b/websocket.js @@ -2,88 +2,88 @@ const socketio = require('socket.io'); const { calculateDistance, getDistance } = require('./src/utils/geolocation/calculateDistance'); let io; -let connections = []; +const connections = []; exports.setupWebsocket = (server) => { - io = socketio(server); + io = socketio(server); - io.on('connection', (socket) => { - const { currentRegion, userId } = socket.handshake.query; - - connections.push({ - id: socket.id, - userId, - currentRegion, - locations: [currentRegion], - categories:[] - }); - + io.on('connection', (socket) => { + const { currentRegion, userId } = socket.handshake.query; + + connections.push({ + id: socket.id, + userId, + currentRegion, + locations: [currentRegion], + categories: [], + }); - socket.on('change-locations', (locations) => { - const index = connections.map((connection) => connection.id).indexOf(socket.id); - if (index >= 0) { - connections[index].locations = locations; - } - }); - socket.on('change-categories', (categories) => { - const index = connections.map((connection) => connection.id).indexOf(socket.id); - if (index >= 0) { - connections[index].categories = categories; - } - }); + socket.on('change-locations', (locations) => { + const index = connections.map((connection) => connection.id).indexOf(socket.id); + if (index >= 0) { + connections[index].locations = locations; + } + }); - socket.on('disconnect', () => { - const index = connections.map((connection) => connection.id).indexOf(socket.id); - if (index >= 0) { - connections.splice(index, 1); - } - }); + socket.on('change-categories', (categories) => { + const index = connections.map((connection) => connection.id).indexOf(socket.id); + if (index >= 0) { + connections[index].categories = categories; + } }); + + socket.on('disconnect', () => { + const index = connections.map((connection) => connection.id).indexOf(socket.id); + if (index >= 0) { + connections.splice(index, 1); + } + }); + }); }; -function canParse(locs){ - try{ - JSON.parse(locs) - return true - }catch{ - return false; - } +function canParse(locs) { + try { + JSON.parse(locs); + return true; + } catch (err) { + return false; + } } exports.findConnections = (coordinates, category, userId) => { - let filtered = connections.filter((connection) => { - if (userId === connection.userId) { - return false - } - if (connection.categories && connection.categories.length) { - const categories = connection.categories; - if (!categories.includes(category)) { - return false; - } - } - let should = false; - let locs = connection.locations; - if(canParse(locs)){ - locs = [JSON.parse(locs)]; - } - locs.every((location) => { - let distance = calculateDistance(coordinates, location); - if (distance < 2) { - distance = getDistance(JSON.parse(connection.currentRegion), coordinates); - connection.distance = distance; - should = true; - return false; - } - return true; - }); - return should; - }) - return filtered + const filtered = connections.filter((connection) => { + if (userId === connection.userId) { + return false; + } + if (connection.categories && connection.categories.length) { + const { categories } = connection; + if (!categories.includes(category)) { + return false; + } + } + let should = false; + let locs = connection.locations; + if (canParse(locs)) { + locs = [JSON.parse(locs)]; + } + locs.every((location) => { + let distance = calculateDistance(coordinates, location); + if (distance < 2) { + distance = getDistance(JSON.parse(connection.currentRegion), coordinates); + connection.distance = distance; + should = true; + return false; + } + return true; + }); + return should; + }); + return filtered; }; exports.sendMessage = (to, message, data) => { - to.forEach((connection) => { - data.distance = connection.distance; - io.to(connection.id).emit(message, data); - }); + to.forEach((connection) => { + data.distance = connection.distance; + io.to(connection.id).emit(message, data); + }); }; diff --git a/yarn.lock b/yarn.lock index 3308e561..606047a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -585,7 +585,7 @@ braces@~3.0.2: dependencies: fill-range "^7.0.1" -bson@^1.1.1, bson@~1.1.1: +bson@^1.1.1, bson@^1.1.4, bson@~1.1.1: version "1.1.4" resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.4.tgz#f76870d799f15b854dffb7ee32f0a874797f7e89" integrity sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q== @@ -2459,6 +2459,19 @@ mongodb@3.5.5: optionalDependencies: saslprep "^1.0.0" +mongodb@^3.5.9: + version "3.5.9" + resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.5.9.tgz#799b72be8110b7e71a882bb7ce0d84d05429f772" + integrity sha512-vXHBY1CsGYcEPoVWhwgxIBeWqP3dSu9RuRDsoLRPTITrcrgm1f0Ubu1xqF9ozMwv53agmEiZm0YGo+7WL3Nbug== + dependencies: + bl "^2.2.0" + bson "^1.1.4" + denque "^1.4.1" + require_optional "^1.0.1" + safe-buffer "^5.1.2" + optionalDependencies: + saslprep "^1.0.0" + mongoose-legacy-pluralize@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz#3ba9f91fa507b5186d399fb40854bff18fb563e4" From cafc6b0cfabc1a6ad5a05a3d3f5606cd3ed01187 Mon Sep 17 00:00:00 2001 From: Welison Almeida Date: Fri, 19 Jun 2020 18:35:43 -0300 Subject: [PATCH 05/28] Undo type comparison with === and !== at some points --- src/config/database.js | 4 ++-- src/services/HelpService.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config/database.js b/src/config/database.js index 5b9ae9b4..9afd0b35 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -23,9 +23,9 @@ const databaseConnect = async () => { await HelpSeed(); await NotificationSeed(); } - } catch (error) { + } catch (err) { console.log('Não foi possível inicicializar corretamente a base de dados!'); - console.log(error); + console.log(err); } }; diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 4b4e6659..f1dbf030 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -176,7 +176,7 @@ class HelpService { if (!help) { throw 'Ajuda não encontrada'; - } else if (help.helperId !== data.helperId) { + } else if (help.helperId != data.helperId) { throw 'Usuário não é o ajudante dessa ajuda'; } else if (help.status === 'owner_finished') { const ownerTitle = 'Pedido de ajuda finalizado!'; @@ -230,7 +230,7 @@ class HelpService { if (!help) { throw 'Ajuda não encontrada'; - } else if (help.ownerId !== data.ownerId) { + } else if (help.ownerId != data.ownerId) { throw 'Usuário não é o dono da ajuda'; } else if (help.status === 'helper_finished') { const ownerTitle = 'Pedido de ajuda finalizado!'; @@ -283,7 +283,7 @@ class HelpService { throw 'Ajuda não encontrada'; } - if (idHelper === help.ownerId) { + if (idHelper == help.ownerId) { throw 'Você não pode ser ajudante de sua própria ajuda'; } if (help.helperId) { From 2428fa248d5b5cd3a7ba5a18412611878e641b85 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Sat, 20 Jun 2020 18:00:11 -0300 Subject: [PATCH 06/28] Create class to save Errors Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- src/models/ErrorHistory.js | 19 + src/repository/ErrorHistoryRepository.js | 21 + src/services/ErrorHistoryService.js | 22 + yarn.lock | 1312 +++++++++++----------- 4 files changed, 696 insertions(+), 678 deletions(-) create mode 100644 src/models/ErrorHistory.js create mode 100644 src/repository/ErrorHistoryRepository.js create mode 100644 src/services/ErrorHistoryService.js diff --git a/src/models/ErrorHistory.js b/src/models/ErrorHistory.js new file mode 100644 index 00000000..4a5d4ca4 --- /dev/null +++ b/src/models/ErrorHistory.js @@ -0,0 +1,19 @@ +const mongoose = require('mongoose'); + +const errorHistorySchema = new mongoose.Schema({ + code: { + type: Number, + required: true, + }, + message: { + type: String, + required: true, + }, + registerDate: { + type: Date, + required: true, + default: Date.now, + }, +}, { collection: 'errorHistory' }); + +module.exports = mongoose.model('ErrorHistory', errorHistorySchema); diff --git a/src/repository/ErrorHistoryRepository.js b/src/repository/ErrorHistoryRepository.js new file mode 100644 index 00000000..58992bfd --- /dev/null +++ b/src/repository/ErrorHistoryRepository.js @@ -0,0 +1,21 @@ +const BaseRepository = require('./BaseRepository'); +const ErrorHistory = require('../models/ErrorHistory'); + +class ErrorHistoryRepository extends BaseRepository { + constructor() { + super(ErrorHistory); + } + + async create(msg, code) { + const data = { + code, + message: msg, + }; + const result = await super.$save(data); + if (!result) { + throw new Error(); + } + } +} + +module.exports = ErrorHistoryRepository; diff --git a/src/services/ErrorHistoryService.js b/src/services/ErrorHistoryService.js new file mode 100644 index 00000000..e7b579df --- /dev/null +++ b/src/services/ErrorHistoryService.js @@ -0,0 +1,22 @@ +const ErrorHistoryRepository = require('../repository/ErrorHistoryRepository'); + +const ErrorHistoryRepository2 = new ErrorHistoryRepository(); +class ErrorHistoryService extends Error { + constructor(message, code) { + super(message); + this.msg = message; + this.code = code; + this.saveError(); + } + + saveError() { + try { + ErrorHistoryRepository2.create(this.msg, this.code); + } catch (err) { + console.log('Não foi possível salvar o erro'); + console.log(err); + } + } +} + +module.exports = ErrorHistoryService; diff --git a/yarn.lock b/yarn.lock index 606047a7..a3b1a86a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3,75 +3,75 @@ "@babel/code-frame@^7.0.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e" - integrity sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g== + version "7.10.3" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.3.tgz#324bcfd8d35cd3d47dae18cde63d752086435e9a" + integrity sha512-fDx9eNW0qz0WkUeqL6tXEXzVlPh6Y5aCDEZesl0xBGA8ndRukX91Uk44ZqnkECp01NAZUdCAl+aiQNGi0k88Eg== dependencies: - "@babel/highlight" "^7.8.3" + "@babel/highlight" "^7.10.3" -"@babel/helper-validator-identifier@^7.9.0": - version "7.9.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz#90977a8e6fbf6b431a7dc31752eee233bf052d80" - integrity sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g== +"@babel/helper-validator-identifier@^7.10.3": + version "7.10.3" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.3.tgz#60d9847f98c4cea1b279e005fdb7c28be5412d15" + integrity sha512-bU8JvtlYpJSBPuj1VUmKpFGaDZuLxASky3LhaKj3bmpSTY6VWooSM8msk+Z0CZoErFye2tlABF6yDkT3FOPAXw== -"@babel/highlight@^7.8.3": - version "7.9.0" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.9.0.tgz#4e9b45ccb82b79607271b2979ad82c7b68163079" - integrity sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ== +"@babel/highlight@^7.10.3": + version "7.10.3" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.10.3.tgz#c633bb34adf07c5c13156692f5922c81ec53f28d" + integrity sha512-Ih9B/u7AtgEnySE2L2F0Xm0GaM729XqqLfHkalTsbjXGyqmf/6M0Cu0WpvqueUlW+xk88BHw9Nkpj49naU+vWw== dependencies: - "@babel/helper-validator-identifier" "^7.9.0" + "@babel/helper-validator-identifier" "^7.10.3" chalk "^2.0.0" js-tokens "^4.0.0" -"@firebase/app-types@0.6.0": - version "0.6.0" - resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.6.0.tgz#8dcc3e793c6983e9d54f7eb623a7618c05f2d94c" - integrity sha512-ld6rzjXk/SUauHiQZJkeuSJpxIZ5wdnWuF5fWBFQNPaxsaJ9kyYg9GqEvwZ1z2e6JP5cU9gwRBlfW1WkGtGDYA== +"@firebase/app-types@0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.6.1.tgz#dcbd23030a71c0c74fc95d4a3f75ba81653850e9" + integrity sha512-L/ZnJRAq7F++utfuoTKX4CLBG5YR7tFO3PLzG1/oXXKEezJ0kRL3CMRoueBEmTCzVb/6SIs2Qlaw++uDgi5Xyg== -"@firebase/auth-interop-types@0.1.4": - version "0.1.4" - resolved "https://registry.yarnpkg.com/@firebase/auth-interop-types/-/auth-interop-types-0.1.4.tgz#e81589f58508630a5bffa604d7c949a0d01ea97b" - integrity sha512-CLKNS84KGAv5lRnHTQZFWoR11Ti7gIPFirDDXWek/fSU+TdYdnxJFR5XSD4OuGyzUYQ3Dq7aVj5teiRdyBl9hA== - -"@firebase/component@0.1.9": - version "0.1.9" - resolved "https://registry.yarnpkg.com/@firebase/component/-/component-0.1.9.tgz#738d1a4c79431a1e899df5de7b310eee370d34ed" - integrity sha512-i58GsVpxBGnKn1rx2RCAH0rk1Ldp6WterfBNDHyxmuyRO6BaZAgvxrZ3Ku1/lqiI7XMbmmRpP3emmwrStbFt9Q== - dependencies: - "@firebase/util" "0.2.44" - tslib "1.11.1" - -"@firebase/database-types@0.4.14": - version "0.4.14" - resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.4.14.tgz#181e10c1d1ae64fd0a080f6e0369cec115c51d70" - integrity sha512-+D41HWac0HcvwMi+0dezEdSOZHpVjPKPNmpQiW2GDuS5kk27/v1jxc9v7F4ALLtpxbVcn16UZl5PqEkcS9H2Xg== - dependencies: - "@firebase/app-types" "0.6.0" - -"@firebase/database@^0.5.17": - version "0.5.25" - resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.5.25.tgz#fa3b00cf315cebd7a29ca1dfd869853b61469534" - integrity sha512-qUIpgDoODWs/FEdCQoH/VwRDvW7nn7m99TGxbMhdiE2WV/nzKbCo/PbbGm0dltdZzQ/SE87E2lfpPGK89Riw6Q== - dependencies: - "@firebase/auth-interop-types" "0.1.4" - "@firebase/component" "0.1.9" - "@firebase/database-types" "0.4.14" - "@firebase/logger" "0.2.1" - "@firebase/util" "0.2.44" +"@firebase/auth-interop-types@0.1.5": + version "0.1.5" + resolved "https://registry.yarnpkg.com/@firebase/auth-interop-types/-/auth-interop-types-0.1.5.tgz#9fc9bd7c879f16b8d1bb08373a0f48c3a8b74557" + integrity sha512-88h74TMQ6wXChPA6h9Q3E1Jg6TkTHep2+k63OWg3s0ozyGVMeY+TTOti7PFPzq5RhszQPQOoCi59es4MaRvgCw== + +"@firebase/component@0.1.14": + version "0.1.14" + resolved "https://registry.yarnpkg.com/@firebase/component/-/component-0.1.14.tgz#2f0d09bbe672dad7afc14bde6f5feeb389740650" + integrity sha512-jbcTAne5mn5T508TY5BFrDOT1v/hXiX/22eMXweCXFbD+9JbsMztwQhNwqjwB8ihNAYG2FKw64UfI9NM04lD/g== + dependencies: + "@firebase/util" "0.2.49" + tslib "^1.11.1" + +"@firebase/database-types@0.5.1": + version "0.5.1" + resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.5.1.tgz#fab2f3fb48eec374a9f435ed21e138635cb9b71c" + integrity sha512-onQxom1ZBYBJ648w/VNRzUewovEDAH7lvnrrpCd69ukkyrMk6rGEO/PQ9BcNEbhlNtukpsqRS0oNOFlHs0FaSA== + dependencies: + "@firebase/app-types" "0.6.1" + +"@firebase/database@^0.6.0": + version "0.6.5" + resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.6.5.tgz#e3b0a23166ca1d2d6308d1dbef82e5fba020ffb8" + integrity sha512-4AnsLUscnCZ48nRGe0YKmHq/cQ4pcM3pRV9O4Uh6mPQpTSixPDLMveuAHYJFUI9tgj5I+FNqjxezUFLS7+9XOw== + dependencies: + "@firebase/auth-interop-types" "0.1.5" + "@firebase/component" "0.1.14" + "@firebase/database-types" "0.5.1" + "@firebase/logger" "0.2.5" + "@firebase/util" "0.2.49" faye-websocket "0.11.3" - tslib "1.11.1" + tslib "^1.11.1" -"@firebase/logger@0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.2.1.tgz#09cdc5d3fe8ba4ed9bf8d6e6ab2a3b5398bd80bb" - integrity sha512-H4nttTqUzEw3TA/JYl8ma6oMSNKHcdpEWV2L2qA+ZEcpM2OLAzagi//DrYBFR5xpPb17IGagpzSxFgx937Sq/A== +"@firebase/logger@0.2.5": + version "0.2.5" + resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.2.5.tgz#bac27bfef32b36e3ecc4b9a5018e9441cb4765e6" + integrity sha512-qqw3m0tWs/qrg7axTZG/QZq24DIMdSY6dGoWuBn08ddq7+GLF5HiqkRj71XznYeUUbfRq5W9C/PSFnN4JxX+WA== -"@firebase/util@0.2.44": - version "0.2.44" - resolved "https://registry.yarnpkg.com/@firebase/util/-/util-0.2.44.tgz#bdf031f2714761ed6062ba2c32edca9113a339af" - integrity sha512-yWnFdeuz7P0QC4oC77JyPdAQ/rTGPDfhHcR5WsoMsKBBHTyqEhaKWL9HeRird+p3AL9M4++ep0FYFNd1UKU3Wg== +"@firebase/util@0.2.49": + version "0.2.49" + resolved "https://registry.yarnpkg.com/@firebase/util/-/util-0.2.49.tgz#01b7e08c2a542e54d9b24b2a93bc5d4de2c5d243" + integrity sha512-SjUoxSqIfcSvDBiMiFEF5SmUOcWNbMH2asJ0VZ1T3vPBlCIRp6tk+T3LMvUWAI8OCnTpbGtpX1fTKiUDLP4xkQ== dependencies: - tslib "1.11.1" + tslib "^1.11.1" "@google-cloud/common@^2.1.1": version "2.4.0" @@ -89,13 +89,13 @@ teeny-request "^6.0.0" "@google-cloud/firestore@^3.0.0": - version "3.7.3" - resolved "https://registry.yarnpkg.com/@google-cloud/firestore/-/firestore-3.7.3.tgz#b8b69b39912e94ff0034218fdc961dd472ad735a" - integrity sha512-6ro45y5FjSbJCRHUQ8PfIu2EbnGNNVoQmKtBnI1YlhlVHaC7oMu+m0cuI0Cr3lLs1mT5iZ0QGyjHTeUYR8pygw== + version "3.8.6" + resolved "https://registry.yarnpkg.com/@google-cloud/firestore/-/firestore-3.8.6.tgz#9e6dea57323a5824563430a759244825fb01d834" + integrity sha512-ox80NbrM1MLJgvAAUd1quFLx/ie/nSjrk1PtscSicpoYDlKb9e6j7pHrVpbopBMyliyfNl3tLJWaDh+x+uCXqw== dependencies: deep-equal "^2.0.0" functional-red-black-tree "^1.0.1" - google-gax "^1.13.0" + google-gax "^1.15.3" readable-stream "^3.4.0" through2 "^3.0.0" @@ -145,10 +145,10 @@ through2 "^3.0.0" xdg-basedir "^4.0.0" -"@grpc/grpc-js@^0.7.4": - version "0.7.6" - resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-0.7.6.tgz#e721ffeb1fdd685a2d31c99a376f53ef8b3b1452" - integrity sha512-koYbq7Fp3BU3D2tHivr/2DLPcv1PoBcuH4Px4gY6/IcSmfOvo+J70LARZCmV6t7FgqORN5hup4IvUgxyWkLJ+A== +"@grpc/grpc-js@~1.0.3": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.0.5.tgz#09948c0810e62828fdd61455b2eb13d7879888b0" + integrity sha512-Hm+xOiqAhcpT9RYM8lc15dbQD7aQurM7ZU8ulmulepiPlN7iwBXXwP3vSBUimoFoApRqz7pSIisXU8pZaCB4og== dependencies: semver "^6.2.0" @@ -253,10 +253,22 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= +"@sindresorhus/is@^0.14.0": + version "0.14.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" + integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== + +"@szmarczak/http-timer@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" + integrity sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA== + dependencies: + defer-to-connect "^1.0.1" + "@tootallnate/once@1": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.0.0.tgz#9c13c2574c92d4503b005feca8f2e16cc1611506" - integrity sha512-KYyTT/T6ALPkIRd2Ge080X/BsXvy9O0hcWTtMWkPvwAwF99+vn6Dv4GzrFT/Nn1LePr+FFDbRXXlqmsy9lw2zA== + version "1.1.2" + resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" + integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== "@types/color-name@^1.1.1": version "1.1.1" @@ -264,31 +276,36 @@ integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== "@types/fs-extra@^8.0.1": - version "8.1.0" - resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.0.tgz#1114834b53c3914806cd03b3304b37b3bd221a4d" - integrity sha512-UoOfVEzAUpeSPmjm7h1uk5MH6KZma2z2O7a75onTGjnNvAvMVrPzPL/vBbT65iIGHWj6rokwfmYcmxmlSf2uwg== + version "8.1.1" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.1.tgz#1e49f22d09aa46e19b51c0b013cb63d0d923a068" + integrity sha512-TcUlBem321DFQzBNuz8p0CLLKp0VvF/XH9E4KHNmgwyp4E3AfgI5cjiIVZWlbfThBop2qxFIh4+LeY6hVWWZ2w== dependencies: "@types/node" "*" -"@types/long@^4.0.0": +"@types/json5@^0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" + integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= + +"@types/long@^4.0.0", "@types/long@^4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== "@types/node@*": - version "13.11.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" - integrity sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ== + version "14.0.13" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.13.tgz#ee1128e881b874c371374c1f72201893616417c9" + integrity sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA== -"@types/node@^10.1.0": - version "10.17.18" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.18.tgz#ae364d97382aacdebf583fa4e7132af2dfe56a0c" - integrity sha512-DQ2hl/Jl3g33KuAUOcMrcAOtsbzb+y/ufakzAdeK9z/H/xsvkpbETZZbPNMIiQuk24f5ZRMCcZIViAwyFIiKmg== +"@types/node@^13.7.0": + version "13.13.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.12.tgz#9c72e865380a7dc99999ea0ef20fc9635b503d20" + integrity sha512-zWz/8NEPxoXNT9YyF2osqyA9WjssZukYpgI4UYZpOjcyqwIUqWGkcCionaEb9Ki+FULyPyvNFpg/329Kd2/pbw== "@types/node@^8.10.59": - version "8.10.59" - resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.59.tgz#9e34261f30183f9777017a13d185dfac6b899e04" - integrity sha512-8RkBivJrDCyPpBXhVZcjh7cQxVBSmRk9QM7hOketZzp6Tg79c0N8kkpAIito9bnJ3HCVCHVYz+KHTEbfQNfeVQ== + version "8.10.61" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.61.tgz#d299136ce54bcaf1abaa4a487f9e4bedf6b0d393" + integrity sha512-l+zSbvT8TPRaCxL1l9cwHCb0tSqGAGcjPJFItGGYat5oCTiq1uQQKYg5m7AF1mgnEBzFXGLJ2LRmNjtreRX76Q== abbrev@1: version "1.1.1" @@ -316,9 +333,9 @@ acorn-jsx@^5.2.0: integrity sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ== acorn@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.1.tgz#e35668de0b402f359de515c5482a1ab9f89a69bf" - integrity sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg== + version "7.3.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.3.1.tgz#85010754db53c3fbaf3b9ea3e083aa5c5d147ffd" + integrity sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA== after@0.8.2: version "0.8.2" @@ -333,21 +350,21 @@ agent-base@6: debug "4" ajv@^6.10.0, ajv@^6.10.2: - version "6.12.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.0.tgz#06d60b96d87b8454a5adaba86e7854da629db4b7" - integrity sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw== + version "6.12.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.2.tgz#c629c5eced17baf314437918d2da88c99d5958cd" + integrity sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ== dependencies: fast-deep-equal "^3.1.1" fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ansi-align@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f" - integrity sha1-w2rsy6VjuJzrVW82kPCx2eNUf38= +ansi-align@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.0.tgz#b536b371cf687caaef236c18d3e21fe3797467cb" + integrity sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw== dependencies: - string-width "^2.0.0" + string-width "^3.0.0" ansi-escapes@^4.2.1: version "4.3.1" @@ -429,7 +446,7 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI= -array-includes@^3.0.3: +array-includes@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.1.tgz#cdd67e6852bdf9c1215460786732255ed2459348" integrity sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ== @@ -438,7 +455,7 @@ array-includes@^3.0.3: es-abstract "^1.17.0" is-string "^1.0.5" -array.prototype.flat@^1.2.1: +array.prototype.flat@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz#0de82b426b0318dbfdb940089e38b043d37f6c7b" integrity sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ== @@ -466,7 +483,7 @@ async-limiter@~1.0.0: resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== -available-typed-arrays@^1.0.0, available-typed-arrays@^1.0.1: +available-typed-arrays@^1.0.0, available-typed-arrays@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz#6b098ca9d8039079ee3f77f7b783c4480ba513f5" integrity sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ== @@ -513,10 +530,10 @@ better-assert@~1.0.0: dependencies: callsite "1.0.0" -bignumber.js@^7.0.0: - version "7.2.1" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f" - integrity sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ== +bignumber.js@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075" + integrity sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A== binary-extensions@^2.0.0: version "2.0.0" @@ -557,18 +574,19 @@ body-parser@1.19.0, body-parser@^1.19.0: raw-body "2.4.0" type-is "~1.6.17" -boxen@^1.2.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b" - integrity sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw== +boxen@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/boxen/-/boxen-4.2.0.tgz#e411b62357d6d6d36587c8ac3d5d974daa070e64" + integrity sha512-eB4uT9RGzg2odpER62bBwSLvUeGC+WbRjjyyFhGsKnc8wp/m0+hQsMUvUe3H2V0D5vw0nBdO1hCJoZo5mKeuIQ== dependencies: - ansi-align "^2.0.0" - camelcase "^4.0.0" - chalk "^2.0.1" - cli-boxes "^1.0.0" - string-width "^2.0.0" - term-size "^1.2.0" - widest-line "^2.0.0" + ansi-align "^3.0.0" + camelcase "^5.3.1" + chalk "^3.0.0" + cli-boxes "^2.2.0" + string-width "^4.1.0" + term-size "^2.1.0" + type-fest "^0.8.1" + widest-line "^3.1.0" brace-expansion@^1.1.7: version "1.1.11" @@ -585,7 +603,7 @@ braces@~3.0.2: dependencies: fill-range "^7.0.1" -bson@^1.1.1, bson@^1.1.4, bson@~1.1.1: +bson@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.4.tgz#f76870d799f15b854dffb7ee32f0a874797f7e89" integrity sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q== @@ -605,6 +623,19 @@ bytes@3.1.0: resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== +cacheable-request@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912" + integrity sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg== + dependencies: + clone-response "^1.0.2" + get-stream "^5.1.0" + http-cache-semantics "^4.0.0" + keyv "^3.0.0" + lowercase-keys "^2.0.0" + normalize-url "^4.1.0" + responselike "^1.0.2" + callsite@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" @@ -615,17 +646,12 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -camelcase@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" - integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= - -capture-stack-trace@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz#a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d" - integrity sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw== +camelcase@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: +chalk@^2.0.0, chalk@^2.1.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -648,9 +674,9 @@ chardet@^0.7.0: integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== chokidar@^3.2.2: - version "3.3.1" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.1.tgz#c84e5b3d18d9a4d77558fef466b1bf16bbeb3450" - integrity sha512-4QYCEWOcK3OJrxwvyyAOxFuhpvOVCYkr33LPfFNBjAD/w3sEzWsp2BUOkI4l9bHvWioAd0rc6NlHUOEaWkTeqg== + version "3.4.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.4.0.tgz#b30611423ce376357c765b9b8f904b9fba3c0be8" + integrity sha512-aXAaho2VJtisB/1fg1+3nlLJqGOuewTzQpd/Tz0yTg2R0e4IGtshYvtjowyEumcBv2z+y4+kc75Mz7j5xJskcQ== dependencies: anymatch "~3.1.1" braces "~3.0.2" @@ -658,7 +684,7 @@ chokidar@^3.2.2: is-binary-path "~2.1.0" is-glob "~4.0.1" normalize-path "~3.0.0" - readdirp "~3.3.0" + readdirp "~3.4.0" optionalDependencies: fsevents "~2.1.2" @@ -667,15 +693,15 @@ chownr@^1.1.1: resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== -ci-info@^1.5.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.6.0.tgz#2ca20dbb9ceb32d4524a683303313f0304b1e497" - integrity sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A== +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== -cli-boxes@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143" - integrity sha1-T6kXw+WclKAEzWH47lCdplFocUM= +cli-boxes@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.0.tgz#538ecae8f9c6ca508e3c3c95b453fe93cb4c168d" + integrity sha512-gpaBrMAizVEANOpfZp/EEUixTXDyGt7DFzdK5hU+UbWt/J0lB0w20ncZj59Z9a93xHb9u12zF5BS6i9RKbtg4w== cli-cursor@^3.1.0: version "3.1.0" @@ -685,9 +711,16 @@ cli-cursor@^3.1.0: restore-cursor "^3.1.0" cli-width@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" - integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= + version "2.2.1" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.1.tgz#b0433d0b4e9c847ef18868a4ef16fd5fc8271c48" + integrity sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw== + +clone-response@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b" + integrity sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws= + dependencies: + mimic-response "^1.0.0" code-point-at@^1.0.0: version "1.1.0" @@ -728,6 +761,11 @@ component-emitter@1.2.1: resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" integrity sha1-E3kY1teCg/ffemt8WmPhQOaUJeY= +component-emitter@~1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" + integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== + component-inherit@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" @@ -755,19 +793,7 @@ concat-stream@^2.0.0: readable-stream "^3.0.2" typedarray "^0.0.6" -configstore@^3.0.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.2.tgz#c6f25defaeef26df12dd33414b001fe81a543f8f" - integrity sha512-vtv5HtGjcYUgFrXc6Kx747B83MRRVS5R1VTEQoXvuP+kMI+if6uywV0nDGoiydJRy4yk7h9od5Og0kxx4zUXmw== - dependencies: - dot-prop "^4.1.0" - graceful-fs "^4.1.2" - make-dir "^1.0.0" - unique-string "^1.0.0" - write-file-atomic "^2.0.0" - xdg-basedir "^3.0.0" - -configstore@^5.0.0: +configstore@^5.0.0, configstore@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/configstore/-/configstore-5.0.1.tgz#d365021b5df4b98cdd187d6a3b0e3f6a7cc5ed96" integrity sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA== @@ -835,35 +861,19 @@ cors@^2.8.5: vary "^1" cpf-cnpj-validator@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/cpf-cnpj-validator/-/cpf-cnpj-validator-1.0.1.tgz#2e9a6a428e30c73bec1187084d49e269674224a6" - integrity sha512-3TYUDkZwo5XyuYqt3MEurOF1CleK2l7TCwYMNw1JWcNAFNoJpdn+0oFyqoBvWjuBZ0ZOn8HNShg9NnI/NU6X7A== + version "1.0.2" + resolved "https://registry.yarnpkg.com/cpf-cnpj-validator/-/cpf-cnpj-validator-1.0.2.tgz#cb729d9a1f6694f8b039460da754dbdb0ec08459" + integrity sha512-U/KU3kSb8DCfylvMal/rn+BhWO+KRwOq9gYtkMiQpH2spi7W2sNugTAxEIBFOiOyMJ3jQB7LTPYSoTbpXDbXyA== dependencies: "@hapi/joi" "^17.1.0" -create-error-class@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" - integrity sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y= - dependencies: - capture-stack-trace "^1.0.0" - cron-parser@^2.7.3: - version "2.13.0" - resolved "https://registry.yarnpkg.com/cron-parser/-/cron-parser-2.13.0.tgz#6f930bb6f2931790d2a9eec83b3ec276e27a6725" - integrity sha512-UWeIpnRb0eyoWPVk+pD3TDpNx3KCFQeezO224oJIkktBrcW6RoAPOx5zIKprZGfk6vcYSmA8yQXItejSaDBhbQ== + version "2.15.0" + resolved "https://registry.yarnpkg.com/cron-parser/-/cron-parser-2.15.0.tgz#04803cd51d8efcfcc6f83ac08e60f3f8c40c7ec5" + integrity sha512-rMFkrQw8+oG5OuwjiXesup4KeIlEG/IU82YtG4xyAHbO5jhKmYaHPp/ZNhq9+7TjSJ65E3zV3kQPUbmXSff2/g== dependencies: - is-nan "^1.2.1" - moment-timezone "^0.5.25" - -cross-spawn@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" - integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= - dependencies: - lru-cache "^4.0.1" - shebang-command "^1.2.0" - which "^1.2.9" + is-nan "^1.3.0" + moment-timezone "^0.5.31" cross-spawn@^6.0.5: version "6.0.5" @@ -876,11 +886,6 @@ cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -crypto-random-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" - integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4= - crypto-random-string@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" @@ -919,10 +924,17 @@ debug@^3.2.6: dependencies: ms "^2.1.1" +decompress-response@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" + integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= + dependencies: + mimic-response "^1.0.0" + deep-equal@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.2.tgz#e68291e245493ae908ca7190c1deea57a01ed82b" - integrity sha512-kX0bjV7tdMuhrhzKPEnVwqfQCuf+IEfN+4Xqv4eKd75xGRyn8yzdQ9ujPY6a221rgJKyQC4KBu1PibDTpa6m9w== + version "2.0.3" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.3.tgz#cad1c15277ad78a5c01c49c2dee0f54de8a6a7b0" + integrity sha512-Spqdl4H+ky45I9ByyJtXteOm9CaIrPmnIPmOhrkKGNYWeDgCvJ8jNYVCTjChxW4FqGuZnLHADc8EKRMX6+CgvA== dependencies: es-abstract "^1.17.5" es-get-iterator "^1.1.0" @@ -930,13 +942,14 @@ deep-equal@^2.0.0: is-date-object "^1.0.2" is-regex "^1.0.5" isarray "^2.0.5" - object-is "^1.0.2" + object-is "^1.1.2" object-keys "^1.1.1" + object.assign "^4.1.0" regexp.prototype.flags "^1.3.0" side-channel "^1.0.2" which-boxed-primitive "^1.0.1" which-collection "^1.0.1" - which-typed-array "^1.1.1" + which-typed-array "^1.1.2" deep-extend@^0.6.0: version "0.6.0" @@ -948,6 +961,11 @@ deep-is@~0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= +defer-to-connect@^1.0.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" + integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== + define-properties@^1.1.2, define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -1002,13 +1020,6 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -dot-prop@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" - integrity sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ== - dependencies: - is-obj "^1.0.0" - dot-prop@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.2.0.tgz#c34ecc29556dc45f1f4c22697b6f4904e0cc4fcb" @@ -1081,11 +1092,11 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1: once "^1.4.0" engine.io-client@~3.4.0: - version "3.4.1" - resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.4.1.tgz#922ddb47eecdcb541136a93aeead24718fd05461" - integrity sha512-RJNmA+A9Js+8Aoq815xpGAsgWH1VoSYM//2VgIiu9lNOaHFfLpTjH4tOzktBpjIs5lvOfiNY1dwf+NuU6D38Mw== + version "3.4.3" + resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.4.3.tgz#192d09865403e3097e3575ebfeb3861c4d01a66c" + integrity sha512-0NGY+9hioejTEJCaSJZfWZLk4FPI9dN+1H1C4+wj2iuFba47UgZbJzfWs4aNFajnX/qAaYKbe2lLTfEEWzCmcw== dependencies: - component-emitter "1.2.1" + component-emitter "~1.3.0" component-inherit "0.0.3" debug "~4.1.0" engine.io-parser "~2.2.0" @@ -1109,9 +1120,9 @@ engine.io-parser@~2.2.0: has-binary2 "~1.0.2" engine.io@~3.4.0: - version "3.4.1" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.4.1.tgz#a61cbc13fa0cb27d9453fd079a29ee980564b069" - integrity sha512-8MfIfF1/IIfxuc2gv5K+XlFZczw/BpTvqBdl0E2fBLkYQp4miv4LuDTVtYt4yMyaIFLEr4vtaSgV4mjvll8Crw== + version "3.4.2" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.4.2.tgz#8fc84ee00388e3e228645e0a7d3dfaeed5bd122c" + integrity sha512-b4Q85dFkGw+TqgytGPrGgACRUhsdKc9S9ErRAXpPGy/CXKs4tYoHDkvIRdsseAF7NjfVwjRFIn6KTnbw7LwJZg== dependencies: accepts "~1.3.4" base64id "2.0.0" @@ -1133,21 +1144,21 @@ error-ex@^1.2.0: is-arrayish "^0.2.1" es-abstract@^1.17.0, es-abstract@^1.17.0-next.1, es-abstract@^1.17.4, es-abstract@^1.17.5: - version "1.17.5" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.5.tgz#d8c9d1d66c8981fb9200e2251d799eee92774ae9" - integrity sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg== + version "1.17.6" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.6.tgz#9142071707857b2cacc7b89ecb670316c3e2d52a" + integrity sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw== dependencies: es-to-primitive "^1.2.1" function-bind "^1.1.1" has "^1.0.3" has-symbols "^1.0.1" - is-callable "^1.1.5" - is-regex "^1.0.5" + is-callable "^1.2.0" + is-regex "^1.1.0" object-inspect "^1.7.0" object-keys "^1.1.1" object.assign "^4.1.0" - string.prototype.trimleft "^2.1.1" - string.prototype.trimright "^2.1.1" + string.prototype.trimend "^1.0.1" + string.prototype.trimstart "^1.0.1" es-get-iterator@^1.1.0: version "1.1.0" @@ -1171,6 +1182,11 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" +escape-goat@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675" + integrity sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q== + escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -1182,23 +1198,23 @@ escape-string-regexp@^1.0.5: integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= eslint-config-airbnb-base@^14.1.0: - version "14.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.1.0.tgz#2ba4592dd6843258221d9bff2b6831bd77c874e4" - integrity sha512-+XCcfGyCnbzOnktDVhwsCAx+9DmrzEmuwxyHUJpw+kqBVT744OUBrB09khgFKlK1lshVww6qXGsYPZpavoNjJw== + version "14.2.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.0.tgz#fe89c24b3f9dc8008c9c0d0d88c28f95ed65e9c4" + integrity sha512-Snswd5oC6nJaevs3nZoLSTvGJBvzTfnBqOIArkf3cbyTyq9UD79wOk8s+RiL6bhca0p/eRO6veczhf6A/7Jy8Q== dependencies: confusing-browser-globals "^1.0.9" object.assign "^4.1.0" - object.entries "^1.1.1" + object.entries "^1.1.2" -eslint-import-resolver-node@^0.3.2: - version "0.3.3" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.3.tgz#dbaa52b6b2816b50bc6711af75422de808e98404" - integrity sha512-b8crLDo0M5RSe5YG8Pu2DYBj71tSB6OvXkfzwbJU2w7y8P4/yo0MyF8jU26IEuEuHF2K5/gcAJE3LhQGqBBbVg== +eslint-import-resolver-node@^0.3.3: + version "0.3.4" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717" + integrity sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA== dependencies: debug "^2.6.9" resolve "^1.13.1" -eslint-module-utils@^2.4.1: +eslint-module-utils@^2.6.0: version "2.6.0" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz#579ebd094f56af7797d19c9866c9c9486629bfa6" integrity sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA== @@ -1207,27 +1223,28 @@ eslint-module-utils@^2.4.1: pkg-dir "^2.0.0" eslint-plugin-import@^2.20.2: - version "2.20.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.20.2.tgz#91fc3807ce08be4837141272c8b99073906e588d" - integrity sha512-FObidqpXrR8OnCh4iNsxy+WACztJLXAHBO5hK79T1Hc77PgQZkyDGA5Ag9xAvRpglvLNxhH/zSmZ70/pZ31dHg== + version "2.21.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.21.2.tgz#8fef77475cc5510801bedc95f84b932f7f334a7c" + integrity sha512-FEmxeGI6yaz+SnEB6YgNHlQK1Bs2DKLM+YF+vuTk5H8J9CLbJLtlPvRFgZZ2+sXiKAlN5dpdlrWOjK8ZoZJpQA== dependencies: - array-includes "^3.0.3" - array.prototype.flat "^1.2.1" + array-includes "^3.1.1" + array.prototype.flat "^1.2.3" contains-path "^0.1.0" debug "^2.6.9" doctrine "1.5.0" - eslint-import-resolver-node "^0.3.2" - eslint-module-utils "^2.4.1" + eslint-import-resolver-node "^0.3.3" + eslint-module-utils "^2.6.0" has "^1.0.3" minimatch "^3.0.4" - object.values "^1.1.0" + object.values "^1.1.1" read-pkg-up "^2.0.0" - resolve "^1.12.0" + resolve "^1.17.0" + tsconfig-paths "^3.9.0" eslint-scope@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9" - integrity sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw== + version "5.1.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.0.tgz#d0f971dfe59c69e0cada684b23d49dbf82600ce5" + integrity sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w== dependencies: esrecurse "^4.1.0" estraverse "^4.1.1" @@ -1240,9 +1257,9 @@ eslint-utils@^1.4.3: eslint-visitor-keys "^1.1.0" eslint-visitor-keys@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" - integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" + integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== eslint@^6.8.0: version "6.8.0" @@ -1302,11 +1319,11 @@ esprima@^4.0.0: integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== esquery@^1.0.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.2.0.tgz#a010a519c0288f2530b3404124bfb5f02e9797fe" - integrity sha512-weltsSqdeWIX9G2qQZz7KlTRJdkkOCTPgLYJUz1Hacf48R4YOwGPHO3+ORfWedqJKbq5WQmsgK90n+pFLIKt/Q== + version "1.3.1" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" + integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== dependencies: - estraverse "^5.0.0" + estraverse "^5.1.0" esrecurse@^4.1.0: version "4.2.1" @@ -1320,10 +1337,10 @@ estraverse@^4.1.0, estraverse@^4.1.1: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== -estraverse@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.0.0.tgz#ac81750b482c11cca26e4b07e83ed8f75fbcdc22" - integrity sha512-j3acdrMzqrxmJTNj5dbr1YbjacrYgAxVMeF0gK16E3j494mOe7xygM/ZLIguEQ0ETwAg2hlJCtHRGav+y0Ny5A== +estraverse@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.1.0.tgz#374309d39fd935ae500e7b92e8a6b4c720e59642" + integrity sha512-FyohXK+R0vE+y1nHLoBM7ZTyqRpqAlhdZHCWIWEviFLiGB8b04H6bQs8G+XTthacvT8VuwvteiP7RJSxMs8UEw== esutils@^2.0.2: version "2.0.3" @@ -1340,19 +1357,6 @@ event-target-shim@^5.0.0: resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== -execa@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" - integrity sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c= - dependencies: - cross-spawn "^5.0.1" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - expo-server-sdk@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/expo-server-sdk/-/expo-server-sdk-3.5.0.tgz#a55c74584d2e7f092e5e416acf02f6583de06ef9" @@ -1417,9 +1421,9 @@ faker@^4.1.0: integrity sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8= fast-deep-equal@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4" - integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA== + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== fast-json-stable-stringify@^2.0.0: version "2.1.0" @@ -1432,9 +1436,9 @@ fast-levenshtein@~2.0.6: integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= fast-text-encoding@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.1.tgz#4a428566f74fc55ebdd447555b1eb4d9cf514455" - integrity sha512-x4FEgaz3zNRtJfLFqJmHWxkMDDvXVtaznj2V9jiP8ACUJrUgist4bP9FmDL2Vew2Y9mEQI/tG4GqabaitYp9CQ== + version "1.0.3" + resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.3.tgz#ec02ac8e01ab8a319af182dae2681213cfe9ce53" + integrity sha512-dtm4QZH9nZtcDt8qJiOH9fcQd1NAgi+K1O2DbE6GG1PPCK/BWfOH3idCTRQ4ImXRUOyopDEgDEnVEE7Y/2Wrig== faye-websocket@0.11.3: version "0.11.3" @@ -1485,11 +1489,11 @@ find-up@^2.0.0, find-up@^2.1.0: locate-path "^2.0.0" firebase-admin@^8.10.0: - version "8.10.0" - resolved "https://registry.yarnpkg.com/firebase-admin/-/firebase-admin-8.10.0.tgz#4a838aec52df49845eba07ad59a40b4df996e815" - integrity sha512-QzJZ1sBh9xzKjb44aP6m1duy0Xe1ixexwh0eaOt1CkJYCOq2b6bievK4GNWMl5yGQ7FFBEbZO6hyDi+5wrctcg== + version "8.12.1" + resolved "https://registry.yarnpkg.com/firebase-admin/-/firebase-admin-8.12.1.tgz#a380c43a9e6ba37dfbe42211a253dd890a442063" + integrity sha512-DZ4Q7QQJYaO2BhnhZLrhL+mGRTCLS5WrxjbJtuKGmbKRBepwMhx++EQA5yhnGnIXgDHnp5SrZnVKygNdXtH8BQ== dependencies: - "@firebase/database" "^0.5.17" + "@firebase/database" "^0.6.0" "@types/node" "^8.10.59" dicer "^0.3.0" jsonwebtoken "8.1.0" @@ -1540,9 +1544,9 @@ fs.realpath@^1.0.0: integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= fsevents@~2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805" - integrity sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA== + version "2.1.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" + integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== function-bind@^1.1.1: version "1.1.1" @@ -1580,9 +1584,9 @@ gaxios@^2.0.0, gaxios@^2.1.0: node-fetch "^2.3.0" gaxios@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/gaxios/-/gaxios-3.0.2.tgz#ec49d0b93713d9efdc51e7a6499536854d8958fd" - integrity sha512-cLOetrsKOBLPwjzVyFzirYaGjrhtYjbKUHp6fQpsio2HH8Mil35JTFQLgkV5D3CCXV7Gnd5V69/m4C9rMBi9bA== + version "3.0.3" + resolved "https://registry.yarnpkg.com/gaxios/-/gaxios-3.0.3.tgz#497730758f5b0d43a32ebdbebe5f1bd9f7db7aed" + integrity sha512-PkzQludeIFhd535/yucALT/Wxyj/y2zLyrMwPcJmnLHDugmV49NvAi/vb+VUq/eWztATZCNcb8ue+ywPG+oLuw== dependencies: abort-controller "^3.0.0" extend "^3.0.2" @@ -1610,10 +1614,19 @@ gcs-resumable-upload@^2.2.4: pumpify "^2.0.0" stream-events "^1.0.4" -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= +get-stream@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" + integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== + dependencies: + pump "^3.0.0" + +get-stream@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.1.0.tgz#01203cdc92597f9b909067c3e656cc1f4d3c4dc9" + integrity sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw== + dependencies: + pump "^3.0.0" glob-parent@^5.0.0, glob-parent@~5.1.0: version "5.1.1" @@ -1634,12 +1647,12 @@ glob@^7.0.5, glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -global-dirs@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445" - integrity sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU= +global-dirs@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-2.0.1.tgz#acdf3bb6685bcd55cb35e8a052266569e9469201" + integrity sha512-5HqUqdhkEovj2Of/ms3IeS/EekcO54ytHRLV4PEY2rhRwrHXLQjeVEES0Lhka0xwNDtGYn58wyC4s5+MHsOO6A== dependencies: - ini "^1.3.4" + ini "^1.3.5" globals@^12.1.0: version "12.4.0" @@ -1663,12 +1676,12 @@ google-auth-library@^5.0.0, google-auth-library@^5.5.0: jws "^4.0.0" lru-cache "^5.0.0" -google-gax@^1.13.0: - version "1.15.2" - resolved "https://registry.yarnpkg.com/google-gax/-/google-gax-1.15.2.tgz#a58aff43ec383f4f056f9d796e8d5e4891161eb8" - integrity sha512-yNNiRf9QxWpZNfQQmSPz3rIDTBDDKnLKY/QEsjCaJyDxttespr6v8WRGgU5KrU/6ZM7QRlgBAYXCkxqHhJp0wA== +google-gax@^1.15.3: + version "1.15.3" + resolved "https://registry.yarnpkg.com/google-gax/-/google-gax-1.15.3.tgz#e88cdcbbd19c7d88cc5fd7d7b932c4d1979a5aca" + integrity sha512-3JKJCRumNm3x2EksUTw4P1Rad43FTpqrtW9jzpf3xSMYXx+ogaqTM1vGo7VixHB4xkAyATXVIa3OcNSh8H9zsQ== dependencies: - "@grpc/grpc-js" "^0.7.4" + "@grpc/grpc-js" "~1.0.3" "@grpc/proto-loader" "^0.5.1" "@types/fs-extra" "^8.0.1" "@types/long" "^4.0.0" @@ -1691,27 +1704,27 @@ google-p12-pem@^2.0.0: dependencies: node-forge "^0.9.0" -got@^6.7.1: - version "6.7.1" - resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" - integrity sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA= +got@^9.6.0: + version "9.6.0" + resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" + integrity sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q== dependencies: - create-error-class "^3.0.0" + "@sindresorhus/is" "^0.14.0" + "@szmarczak/http-timer" "^1.1.2" + cacheable-request "^6.0.0" + decompress-response "^3.3.0" duplexer3 "^0.1.4" - get-stream "^3.0.0" - is-redirect "^1.0.0" - is-retry-allowed "^1.0.0" - is-stream "^1.0.0" - lowercase-keys "^1.0.0" - safe-buffer "^5.0.1" - timed-out "^4.0.0" - unzip-response "^2.0.1" - url-parse-lax "^1.0.0" - -graceful-fs@^4.1.11, graceful-fs@^4.1.2: - version "4.2.3" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" - integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ== + get-stream "^4.1.0" + lowercase-keys "^1.0.1" + mimic-response "^1.0.1" + p-cancelable "^1.0.0" + to-readable-stream "^1.0.0" + url-parse-lax "^3.0.0" + +graceful-fs@^4.1.2: + version "4.2.4" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" + integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== gtoken@^4.1.0: version "4.1.4" @@ -1755,6 +1768,11 @@ has-unicode@^2.0.0: resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= +has-yarn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/has-yarn/-/has-yarn-2.1.0.tgz#137e11354a7b5bf11aa5cb649cf0c6f3ff2b2e77" + integrity sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw== + has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" @@ -1763,9 +1781,9 @@ has@^1.0.3: function-bind "^1.1.1" hash-stream-validation@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/hash-stream-validation/-/hash-stream-validation-0.2.2.tgz#6b34c4fce5e9fce265f1d3380900049d92a10090" - integrity sha512-cMlva5CxWZOrlS/cY0C+9qAzesn5srhFA8IT1VPiHc9bWWBLkJfEUIZr7MWoi89oOOGmpg8ymchaOjiArsGu5A== + version "0.2.3" + resolved "https://registry.yarnpkg.com/hash-stream-validation/-/hash-stream-validation-0.2.3.tgz#44e3479d1767c4f1d6924cc2da61eca08ebba8af" + integrity sha512-OEohGLoUOh+bwsIpHpdvhIXFyRGjeLqJbT8Yc5QTZPbRM7LKywagTQxnX/6mghLDOrD9YGz88hy5mLN2eKflYQ== dependencies: through2 "^2.0.0" @@ -1774,6 +1792,11 @@ hosted-git-info@^2.1.4: resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== +http-cache-semantics@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390" + integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== + http-errors@1.7.2: version "1.7.2" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f" @@ -1796,10 +1819,10 @@ http-errors@~1.7.2: statuses ">= 1.5.0 < 2" toidentifier "1.0.0" -"http-parser-js@>=0.4.0 <0.4.11": - version "0.4.10" - resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.4.10.tgz#92c9c1374c35085f75db359ec56cc257cbb93fa4" - integrity sha1-ksnBN0w1CF912zWexWzCV8u5P6Q= +http-parser-js@>=0.5.1: + version "0.5.2" + resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.2.tgz#da2e31d237b393aae72ace43882dd7e270a8ff77" + integrity sha512-opCO9ASqg5Wy2FNo7A0sxy71yGbbkJJXLdgMK04Tcypw9jr2MgWbyubb0+WdmDmGnFflO7fRbqbaihh/ENDlRQ== http-proxy-agent@^4.0.0: version "4.0.1" @@ -1883,15 +1906,15 @@ inherits@2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= -ini@^1.3.4, ini@~1.3.0: +ini@^1.3.5, ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== inquirer@^7.0.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.1.0.tgz#1298a01859883e17c7264b82870ae1034f92dd29" - integrity sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg== + version "7.2.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.2.0.tgz#63ce99d823090de7eb420e4bb05e6f3449aa389a" + integrity sha512-E0c4rPwr9ByePfNlTIB8z51kK1s2n6jrHuJeEHENl/sbq2G/S1auvibgEwNR4uSyiU+PiYHqSwsgGiXjG8p5ZQ== dependencies: ansi-escapes "^4.2.1" chalk "^3.0.0" @@ -1939,17 +1962,17 @@ is-boolean-object@^1.0.0: resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.0.1.tgz#10edc0900dd127697a92f6f9807c7617d68ac48e" integrity sha512-TqZuVwa/sppcrhUCAYkGBk7w0yxfQQnxq28fjkO53tnK9FQXmdwz2JS5+GjsWQ6RByES1K40nI+yDic5c9/aAQ== -is-callable@^1.1.4, is-callable@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" - integrity sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q== +is-callable@^1.1.4, is-callable@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.0.tgz#83336560b54a38e35e3a2df7afd0454d691468bb" + integrity sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw== -is-ci@^1.0.10: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.2.1.tgz#e3779c8ee17fccf428488f6e281187f2e632841c" - integrity sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg== +is-ci@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== dependencies: - ci-info "^1.5.0" + ci-info "^2.0.0" is-date-object@^1.0.1, is-date-object@^1.0.2: version "1.0.2" @@ -1985,30 +2008,30 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1: dependencies: is-extglob "^2.1.1" -is-installed-globally@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.1.0.tgz#0dfd98f5a9111716dd535dda6492f67bf3d25a80" - integrity sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA= +is-installed-globally@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.3.2.tgz#fd3efa79ee670d1187233182d5b0a1dd00313141" + integrity sha512-wZ8x1js7Ia0kecP/CHM/3ABkAmujX7WPvQk6uu3Fly/Mk44pySulQpnHG46OMjHGXApINnV4QhY3SWnECO2z5g== dependencies: - global-dirs "^0.1.0" - is-path-inside "^1.0.0" + global-dirs "^2.0.1" + is-path-inside "^3.0.1" is-map@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.1.tgz#520dafc4307bb8ebc33b813de5ce7c9400d644a1" integrity sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw== -is-nan@^1.2.1: +is-nan@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.0.tgz#85d1f5482f7051c2019f5673ccebdb06f3b0db03" integrity sha512-z7bbREymOqt2CCaZVly8aC4ML3Xhfi0ekuOnjO2L8vKdl+CttdVoGZQhd4adMFAsxQ5VeRVwORs4tU8RH+HFtQ== dependencies: define-properties "^1.1.3" -is-npm@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" - integrity sha1-8vtjpl5JBbQGyGBydloaTceTufQ= +is-npm@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-4.0.0.tgz#c90dd8380696df87a7a6d823c20d0b12bbe3c84d" + integrity sha512-96ECIfh9xtDDlPylNPXhzjsykHsMJZ18ASpaWzQyBr4YRTcVjUvzaHayDAES2oU/3KpljhHUjtSRNiDwi0F0ig== is-number-object@^1.0.3: version "1.0.4" @@ -2020,44 +2043,22 @@ is-number@^7.0.0: resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== -is-obj@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" - integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8= - is-obj@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982" integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w== -is-path-inside@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" - integrity sha1-jvW33lBDej/cprToZe96pVy0gDY= - dependencies: - path-is-inside "^1.0.1" - -is-promise@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" - integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o= - -is-redirect@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" - integrity sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ= +is-path-inside@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.2.tgz#f5220fc82a3e233757291dddc9c5877f2a1f3017" + integrity sha512-/2UGPSgmtqwo1ktx8NDHjuPwZWmHhO+gj0f93EkhLB5RgW9RZevWYYlIkS6zePc6U2WpOdQYIwHe9YC4DWEBVg== -is-regex@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" - integrity sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ== +is-regex@^1.0.5, is-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.0.tgz#ece38e389e490df0dc21caea2bd596f987f767ff" + integrity sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw== dependencies: - has "^1.0.3" - -is-retry-allowed@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4" - integrity sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg== + has-symbols "^1.0.1" is-set@^2.0.1: version "2.0.1" @@ -2069,11 +2070,6 @@ is-stream-ended@^0.1.4: resolved "https://registry.yarnpkg.com/is-stream-ended/-/is-stream-ended-0.1.4.tgz#f50224e95e06bce0e356d440a4827cd35b267eda" integrity sha512-xj0XPvmr7bQFTvirqnFr50o0hQIh6ZItDqloxt5aJrR4NQsYeSsyFQERYGCAzfindAcnKjINnwEEgLx4IqVzQw== -is-stream@^1.0.0, is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= - is-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3" @@ -2116,6 +2112,11 @@ is-weakset@^2.0.1: resolved "https://registry.yarnpkg.com/is-weakset/-/is-weakset-2.0.1.tgz#e9a0af88dbd751589f5e50d80f4c98b780884f83" integrity sha512-pi4vhbhVHGLxohUw7PhGsueT4vRGFoXhP7+RGN0jKIv9+8PWYCQTqtADngrxOm2g46hoH0+g8uZZBzMrvVGDmw== +is-yarn-global@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/is-yarn-global/-/is-yarn-global-0.3.0.tgz#d502d3382590ea3004893746754c89139973e232" + integrity sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw== + isarray@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e" @@ -2142,19 +2143,24 @@ js-tokens@^4.0.0: integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== js-yaml@^3.13.1: - version "3.13.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" - integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== + version "3.14.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482" + integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== dependencies: argparse "^1.0.7" esprima "^4.0.0" json-bigint@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.3.0.tgz#0ccd912c4b8270d05f056fbd13814b53d3825b1e" - integrity sha1-DM2RLEuCcNBfBW+9E4FLU9OCWx4= + version "0.3.1" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-0.3.1.tgz#0c1729d679f580d550899d6a2226c228564afe60" + integrity sha512-DGWnSzmusIreWlEupsUelHrhwmPPE+FiQvg+drKfk2p+bdEYa5mp4PJ8JsCWqae0M2jQNb0HPvnwvf1qOTThzQ== dependencies: - bignumber.js "^7.0.0" + bignumber.js "^9.0.0" + +json-buffer@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" + integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg= json-schema-traverse@^0.4.1: version "0.4.1" @@ -2166,6 +2172,13 @@ json-stable-stringify-without-jsonify@^1.0.1: resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= +json5@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" + integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + dependencies: + minimist "^1.2.0" + jsonwebtoken@8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.1.0.tgz#c6397cd2e5fd583d65c007a83dc7bb78e6982b83" @@ -2221,12 +2234,19 @@ kareem@2.3.1: resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.1.tgz#def12d9c941017fabfb00f873af95e9c99e1be87" integrity sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw== -latest-version@^3.0.0: +keyv@^3.0.0: version "3.1.0" - resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" - integrity sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU= + resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" + integrity sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA== dependencies: - package-json "^4.0.0" + json-buffer "3.0.0" + +latest-version@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-5.1.0.tgz#119dfe908fe38d15dfa43ecd13fa12ec8832face" + integrity sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA== + dependencies: + package-json "^6.3.0" levn@^0.3.0, levn@~0.3.0: version "0.3.0" @@ -2319,18 +2339,15 @@ long@^4.0.0: resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== -lowercase-keys@^1.0.0: +lowercase-keys@^1.0.0, lowercase-keys@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== -lru-cache@^4.0.1: - version "4.1.5" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" - integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== - dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" +lowercase-keys@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" + integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== lru-cache@^5.0.0: version "5.1.1" @@ -2339,17 +2356,10 @@ lru-cache@^5.0.0: dependencies: yallist "^3.0.2" -make-dir@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" - integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== - dependencies: - pify "^3.0.0" - make-dir@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.0.2.tgz#04a1acbf22221e1d6ef43559f43e05a90dbb4392" - integrity sha512-rYKABKutXa6vXTXhoV18cBE7PaewPXHe/Bdq4v+ZLMhxbWApkFFplT0LcbMW+6BbjnQXzZ/sAvSE/JdguApG5w== + version "3.1.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" + integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== dependencies: semver "^6.0.0" @@ -2373,17 +2383,17 @@ methods@~1.1.2: resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= -mime-db@1.43.0, "mime-db@>= 1.43.0 < 2": - version "1.43.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.43.0.tgz#0a12e0502650e473d735535050e7c8f4eb4fae58" - integrity sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ== +mime-db@1.44.0, "mime-db@>= 1.43.0 < 2": + version "1.44.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" + integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== mime-types@^2.0.8, mime-types@~2.1.24: - version "2.1.26" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.26.tgz#9c921fc09b7e149a65dfdc0da4d20997200b0a06" - integrity sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ== + version "2.1.27" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" + integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== dependencies: - mime-db "1.43.0" + mime-db "1.44.0" mime@1.6.0: version "1.6.0" @@ -2391,15 +2401,20 @@ mime@1.6.0: integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== mime@^2.2.0: - version "2.4.4" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.4.tgz#bd7b91135fc6b01cde3e9bae33d659b63d8857e5" - integrity sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA== + version "2.4.6" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1" + integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA== mimic-fn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== +mimic-response@^1.0.0, mimic-response@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" + integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== + minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" @@ -2434,32 +2449,19 @@ mkdirp@^0.5.0, mkdirp@^0.5.1: dependencies: minimist "^1.2.5" -moment-timezone@^0.5.25: - version "0.5.28" - resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.28.tgz#f093d789d091ed7b055d82aa81a82467f72e4338" - integrity sha512-TDJkZvAyKIVWg5EtVqRzU97w0Rb0YVbfpqyjgu6GwXCAohVRqwZjf4fOzDE6p1Ch98Sro/8hQQi65WDXW5STPw== +moment-timezone@^0.5.31: + version "0.5.31" + resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.31.tgz#9c40d8c5026f0c7ab46eda3d63e49c155148de05" + integrity sha512-+GgHNg8xRhMXfEbv81iDtrVeTcWt0kWmTEY1XQK14dICTXnWJnT0dxdlPspwqF3keKMVPXwayEsk1DI0AA/jdA== dependencies: moment ">= 2.9.0" "moment@>= 2.9.0": - version "2.24.0" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b" - integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg== - -mongodb@3.5.5: - version "3.5.5" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.5.5.tgz#1334c3e5a384469ac7ef0dea69d59acc829a496a" - integrity sha512-GCjDxR3UOltDq00Zcpzql6dQo1sVry60OXJY3TDmFc2SWFY6c8Gn1Ardidc5jDirvJrx2GC3knGOImKphbSL3A== - dependencies: - bl "^2.2.0" - bson "^1.1.1" - denque "^1.4.1" - require_optional "^1.0.1" - safe-buffer "^5.1.2" - optionalDependencies: - saslprep "^1.0.0" + version "2.27.0" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.27.0.tgz#8bff4e3e26a236220dfe3e36de756b6ebaa0105d" + integrity sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ== -mongodb@^3.5.9: +mongodb@3.5.9, mongodb@^3.5.9: version "3.5.9" resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.5.9.tgz#799b72be8110b7e71a882bb7ce0d84d05429f772" integrity sha512-vXHBY1CsGYcEPoVWhwgxIBeWqP3dSu9RuRDsoLRPTITrcrgm1f0Ubu1xqF9ozMwv53agmEiZm0YGo+7WL3Nbug== @@ -2478,15 +2480,15 @@ mongoose-legacy-pluralize@1.0.2: integrity sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ== mongoose@^5.9.6: - version "5.9.7" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.9.7.tgz#03c581860d0e2f60f6008f9457ab0c2905609875" - integrity sha512-WJOBh9WMvivqBK8my9HFtSzSySKdUxJPNGAwswEakAasWUcPXJl3yHMtZ4ngGnKbwTT9KnAr75xamlt/PouR9w== + version "5.9.19" + resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.9.19.tgz#fadedce84e3f49b7ea335b73d2a60d2df97d69e1" + integrity sha512-wJ5FR2ykvyd17MRHA6sku/N1CMaC/kf4CnN357htD48RpzJhW60YDkxPSPLbkLg8Woa+i7jYi0glhzC0EcBcRQ== dependencies: - bson "~1.1.1" + bson "^1.1.4" kareem "2.3.1" - mongodb "3.5.5" + mongodb "3.5.9" mongoose-legacy-pluralize "1.0.2" - mpath "0.6.0" + mpath "0.7.0" mquery "3.2.2" ms "2.1.2" regexp-clone "1.0.0" @@ -2494,10 +2496,10 @@ mongoose@^5.9.6: sift "7.0.1" sliced "1.0.1" -mpath@0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.6.0.tgz#aa922029fca4f0f641f360e74c5c1b6a4c47078e" - integrity sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw== +mpath@0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.7.0.tgz#20e8102e276b71709d6e07e9f8d4d0f641afbfb8" + integrity sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg== mquery@3.2.2: version "3.2.2" @@ -2536,9 +2538,9 @@ natural-compare@^1.4.0: integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= needle@^2.2.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/needle/-/needle-2.4.1.tgz#14af48732463d7475696f937626b1b993247a56a" - integrity sha512-x/gi6ijr4B7fwl6WYL9FwlCvRQKGlUNvnceho8wxkwXqN8jvVmmmATTmZPRRG7b/yC1eode26C2HO9jl78Du9g== + version "2.5.0" + resolved "https://registry.yarnpkg.com/needle/-/needle-2.5.0.tgz#e6fc4b3cc6c25caed7554bd613a5cf0bac8c31c0" + integrity sha512-o/qITSDR0JCyCKEQ1/1bnUXMmznxabbwi/Y4WwJElf+evwJNFNwIDMCCt5IigFVxgeGBJESLohGtIS9gEzo1fA== dependencies: debug "^3.2.6" iconv-lite "^0.4.4" @@ -2555,9 +2557,9 @@ nice-try@^1.0.4: integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== node-addon-api@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.0.tgz#f9afb8d777a91525244b01775ea0ddbe1125483b" - integrity sha512-ASCL5U13as7HhOExbT6OlWJJUV/lLzL2voOSP1UVehpRD8FbSrSDjfScK/KwAvVTI5AS6r4VwbOMlIqtvRidnA== + version "2.0.1" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.1.tgz#4fd0931bf6d7e48b219ff3e6abc73cbb0252b7a3" + integrity sha512-2WVfwRfIr1AVn3dRq4yRc2Hn35ND+mPJH6inC6bjpYCZVrpXPB4j3T6i//OGVfqVsR1t/X/axRulDsheq4F0LQ== node-fetch@^2.2.0, node-fetch@^2.3.0, node-fetch@^2.6.0: version "2.6.0" @@ -2600,9 +2602,9 @@ node-schedule@^1.3.2: sorted-array-functions "^1.0.0" nodemon@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.2.tgz#9c7efeaaf9b8259295a97e5d4585ba8f0cbe50b0" - integrity sha512-GWhYPMfde2+M0FsHnggIHXTqPDHXia32HRhh6H0d75Mt9FKUoCBvumNHr7LdrpPBTKxsWmIEOjoN+P4IU6Hcaw== + version "2.0.4" + resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.4.tgz#55b09319eb488d6394aa9818148c0c2d1c04c416" + integrity sha512-Ltced+hIfTmaS28Zjv1BM552oQ3dbwPqI4+zI0SLgq+wpJhSyqgYude/aZa/3i31VCQWMfXJVxvu86abcam3uQ== dependencies: chokidar "^3.2.2" debug "^3.2.6" @@ -2613,7 +2615,7 @@ nodemon@^2.0.2: supports-color "^5.5.0" touch "^3.1.0" undefsafe "^2.0.2" - update-notifier "^2.5.0" + update-notifier "^4.0.0" nopt@^4.0.1: version "4.0.3" @@ -2645,6 +2647,11 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== +normalize-url@^4.1.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129" + integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ== + npm-bundled@^1.0.1: version "1.1.1" resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.1.tgz#1edd570865a94cdb1bc8220775e29466c9fb234b" @@ -2666,13 +2673,6 @@ npm-packlist@^1.1.6: npm-bundled "^1.0.1" npm-normalize-package-bin "^1.0.1" -npm-run-path@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" - integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= - dependencies: - path-key "^2.0.0" - npmlog@^4.0.2: version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" @@ -2699,14 +2699,17 @@ object-component@0.0.3: integrity sha1-8MaapQ78lbhmwYb0AKM3acsvEpE= object-inspect@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" - integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw== + version "1.8.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" + integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA== -object-is@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.0.2.tgz#6b80eb84fe451498f65007982f035a5b445edec4" - integrity sha512-Epah+btZd5wrrfjkJZq1AOB9O6OxUQto45hzFd7lXGrpHPGE0W1k+426yrZV+k6NJOzLNNW/nVsmZdIWsAqoOQ== +object-is@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.2.tgz#c5d2e87ff9e119f78b7a088441519e2eec1573b6" + integrity sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" @@ -2723,17 +2726,16 @@ object.assign@^4.1.0: has-symbols "^1.0.0" object-keys "^1.0.11" -object.entries@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.1.tgz#ee1cf04153de02bb093fec33683900f57ce5399b" - integrity sha512-ilqR7BgdyZetJutmDPfXCDffGa0/Yzl2ivVNpbx/g4UeWrCdRnFDUBrKJGLhGieRHDATnyZXWBeCb29k9CJysQ== +object.entries@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.2.tgz#bc73f00acb6b6bb16c203434b10f9a7e797d3add" + integrity sha512-BQdB9qKmb/HyNdMNWVr7O3+z5MUIx3aiegEIJqjMBbBf0YT9RRxTJSim4mzFqtyr7PDAHigq0N9dO0m0tRakQA== dependencies: define-properties "^1.1.3" - es-abstract "^1.17.0-next.1" - function-bind "^1.1.1" + es-abstract "^1.17.5" has "^1.0.3" -object.values@^1.1.0: +object.values@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.1.tgz#68a99ecde356b7e9295a3c5e0ce31dc8c953de5e" integrity sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA== @@ -2794,10 +2796,10 @@ osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= +p-cancelable@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc" + integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw== p-limit@^1.1.0: version "1.3.0" @@ -2830,15 +2832,15 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== -package-json@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/package-json/-/package-json-4.0.1.tgz#8869a0401253661c4c4ca3da6c2121ed555f5eed" - integrity sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0= +package-json@^6.3.0: + version "6.5.0" + resolved "https://registry.yarnpkg.com/package-json/-/package-json-6.5.0.tgz#6feedaca35e75725876d0b0e64974697fed145b0" + integrity sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ== dependencies: - got "^6.7.1" - registry-auth-token "^3.0.1" - registry-url "^3.0.3" - semver "^5.1.0" + got "^9.6.0" + registry-auth-token "^4.0.0" + registry-url "^5.0.0" + semver "^6.2.0" parent-module@^1.0.0: version "1.0.1" @@ -2883,12 +2885,7 @@ path-is-absolute@^1.0.0: resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= -path-is-inside@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" - integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= - -path-key@^2.0.0, path-key@^2.0.1: +path-key@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= @@ -2910,7 +2907,7 @@ path-type@^2.0.0: dependencies: pify "^2.0.0" -picomatch@^2.0.4, picomatch@^2.0.7: +picomatch@^2.0.4, picomatch@^2.2.1: version "2.2.2" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== @@ -2920,11 +2917,6 @@ pify@^2.0.0: resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= -pify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= - pkg-dir@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" @@ -2937,10 +2929,10 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prepend-http@^1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" - integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= +prepend-http@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" + integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= process-nextick-args@~2.0.0: version "2.0.1" @@ -2958,9 +2950,9 @@ promise-limit@^2.7.0: integrity sha512-7nJ6v5lnJsXwGprnGXga4wx6d1POjvi5Qmf1ivTRxTjH4Z/9Czja/UCMLVmB9N93GeWOU93XaFaEt6jbuoagNw== protobufjs@^6.8.6, protobufjs@^6.8.9: - version "6.8.9" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.9.tgz#0b1adbcdaa983d369c3d9108a97c814edc030754" - integrity sha512-j2JlRdUeL/f4Z6x4aU4gj9I2LECglC+5qR2TrWb193Tla1qfdaNQTZ8I27Pt7K0Ajmvjjpft7O3KWTGciz4gpw== + version "6.9.0" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.9.0.tgz#c08b2bf636682598e6fabbf0edb0b1256ff090bd" + integrity sha512-LlGVfEWDXoI/STstRDdZZKb/qusoAWUnmLg9R8OLSO473mBLWHowx8clbX5/+mKDEI+v7GzjoK9tRPZMMcoTrg== dependencies: "@protobufjs/aspromise" "^1.1.2" "@protobufjs/base64" "^1.1.2" @@ -2972,8 +2964,8 @@ protobufjs@^6.8.6, protobufjs@^6.8.9: "@protobufjs/path" "^1.1.2" "@protobufjs/pool" "^1.1.0" "@protobufjs/utf8" "^1.1.0" - "@types/long" "^4.0.0" - "@types/node" "^10.1.0" + "@types/long" "^4.0.1" + "@types/node" "^13.7.0" long "^4.0.0" proxy-addr@~2.0.5: @@ -2984,15 +2976,10 @@ proxy-addr@~2.0.5: forwarded "~0.1.2" ipaddr.js "1.9.1" -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= - pstree.remy@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/pstree.remy/-/pstree.remy-1.1.7.tgz#c76963a28047ed61542dc361aa26ee55a7fa15f3" - integrity sha512-xsMgrUwRpuGskEzBFkH8NmTimbZ5PcPup0LA8JJkHIm2IMUbQcpo3yeLNWVrufEYjh8YwtSVh0xz6UeWc5Oh5A== + version "1.1.8" + resolved "https://registry.yarnpkg.com/pstree.remy/-/pstree.remy-1.1.8.tgz#c242224f4a67c21f686839bbdb4ac282b8373d3a" + integrity sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w== pump@^3.0.0: version "3.0.0" @@ -3016,6 +3003,13 @@ punycode@^2.1.0: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== +pupa@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.0.1.tgz#dbdc9ff48ffbea4a26a069b6f9f7abb051008726" + integrity sha512-hEJH0s8PXLY/cdXh66tNEQGndDrIKNqNC5xmrysZy3i5C3oEoLna7YAOad+7u125+zH1HNXUmGEkrhb3c2VriA== + dependencies: + escape-goat "^2.0.0" + qs@6.7.0: version "6.7.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" @@ -3036,7 +3030,7 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -rc@^1.0.1, rc@^1.1.6, rc@^1.2.7: +rc@^1.2.7, rc@^1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== @@ -3085,12 +3079,12 @@ readable-stream@^2.0.0, readable-stream@^2.0.6, readable-stream@^2.3.5, readable string_decoder "~1.1.1" util-deprecate "~1.0.1" -readdirp@~3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.3.0.tgz#984458d13a1e42e2e9f5841b129e162f369aff17" - integrity sha512-zz0pAkSPOXXm1viEwygWIPSPkcBYjW1xU5j/JBh5t9bGCJwa6f9+BJa6VaB2g+b55yVrmXzqkyLf4xaWYM0IkQ== +readdirp@~3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz#9fdccdf9e9155805449221ac645e8303ab5b9ada" + integrity sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ== dependencies: - picomatch "^2.0.7" + picomatch "^2.2.1" regexp-clone@1.0.0, regexp-clone@^1.0.0: version "1.0.0" @@ -3110,20 +3104,19 @@ regexpp@^2.0.1: resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== -registry-auth-token@^3.0.1: - version "3.4.0" - resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.4.0.tgz#d7446815433f5d5ed6431cd5dca21048f66b397e" - integrity sha512-4LM6Fw8eBQdwMYcES4yTnn2TqIasbXuwDx3um+QRs7S55aMKCBKBxvPXl2RiUjHwuJLTyYfxSpmfSAjQpcuP+A== +registry-auth-token@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-4.1.1.tgz#40a33be1e82539460f94328b0f7f0f84c16d9479" + integrity sha512-9bKS7nTl9+/A1s7tnPeGrUpRcVY+LUh7bfFgzpndALdPfXQBfQV77rQVtqgUV3ti4vc/Ik81Ex8UJDWDQ12zQA== dependencies: - rc "^1.1.6" - safe-buffer "^5.0.1" + rc "^1.2.8" -registry-url@^3.0.3: - version "3.1.0" - resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" - integrity sha1-PU74cPc93h138M+aOBQyRE4XSUI= +registry-url@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-5.1.0.tgz#e98334b50d5434b81136b44ec638d9c2009c5009" + integrity sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw== dependencies: - rc "^1.0.1" + rc "^1.2.8" require_optional@^1.0.1: version "1.0.1" @@ -3143,13 +3136,20 @@ resolve-from@^4.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13.1: - version "1.15.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8" - integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w== +resolve@^1.10.0, resolve@^1.13.1, resolve@^1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== dependencies: path-parse "^1.0.6" +responselike@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" + integrity sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec= + dependencies: + lowercase-keys "^1.0.0" + restore-cursor@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" @@ -3181,11 +3181,9 @@ rimraf@^2.6.1: glob "^7.1.3" run-async@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.0.tgz#e59054a5b86876cfae07f431d18cbaddc594f1e8" - integrity sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg== - dependencies: - is-promise "^2.1.0" + version "2.4.1" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" + integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== rxjs@^6.5.3: version "6.5.5" @@ -3200,9 +3198,9 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519" - integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg== + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== "safer-buffer@>= 2.1.2 < 3": version "2.1.2" @@ -3221,19 +3219,19 @@ sax@^1.2.4: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== -semver-diff@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" - integrity sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY= +semver-diff@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-3.1.1.tgz#05f77ce59f325e00e2706afd67bb506ddb1ca32b" + integrity sha512-GX0Ix/CJcHyB8c4ykpHGIAvLyOwOobtM/8d+TQkAd81/bEjgPHrfba41Vpesr7jX/t8Uh+R3EX9eAS5be+jQYg== dependencies: - semver "^5.0.3" + semver "^6.3.0" -"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.5.0, semver@^5.7.1: +"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.3.0, semver@^5.5.0, semver@^5.7.1: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@^6.0.0, semver@^6.1.2, semver@^6.2.0: +semver@^6.0.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== @@ -3361,9 +3359,9 @@ socket.io-parser@~3.3.0: isarray "2.0.1" socket.io-parser@~3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.4.0.tgz#370bb4a151df2f77ce3345ff55a7072cc6e9565a" - integrity sha512-/G/VOI+3DBp0+DJKW4KesGnQkQPFmUCbA/oO2QGT6CWxU7hLGWqU3tyuzeSK/dqcyeHsQg1vTe9jiZI8GU9SCQ== + version "3.4.1" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.4.1.tgz#b06af838302975837eab2dc980037da24054d64a" + integrity sha512-11hMgzL+WCLWf1uFtHSNvliI++tcRUWdoeYuwIl+Axvwy9z2gQM+7nJyN3STj1tLj5JyIUH8/gpDGxzAlDdi0A== dependencies: component-emitter "1.2.1" debug "~4.1.0" @@ -3394,22 +3392,22 @@ sparse-bitfield@^3.0.3: memory-pager "^1.0.2" spdx-correct@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" - integrity sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q== + version "3.1.1" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" + integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== dependencies: spdx-expression-parse "^3.0.0" spdx-license-ids "^3.0.0" spdx-exceptions@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz#2ea450aee74f2a89bfb94519c07fcd6f41322977" - integrity sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA== + version "2.3.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== spdx-expression-parse@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0" - integrity sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg== + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== dependencies: spdx-exceptions "^2.1.0" spdx-license-ids "^3.0.0" @@ -3455,7 +3453,7 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.1: +"string-width@^1.0.2 || 2": version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== @@ -3472,7 +3470,7 @@ string-width@^3.0.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" -string-width@^4.1.0: +string-width@^4.0.0, string-width@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== @@ -3481,36 +3479,18 @@ string-width@^4.1.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" -string.prototype.trimend@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.0.tgz#ee497fd29768646d84be2c9b819e292439614373" - integrity sha512-EEJnGqa/xNfIg05SxiPSqRS7S9qwDhYts1TSLR1BQfYUfPe1stofgGKvwERK9+9yf+PpfBMlpBaCHucXGPQfUA== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - -string.prototype.trimleft@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.2.tgz#4408aa2e5d6ddd0c9a80739b087fbc067c03b3cc" - integrity sha512-gCA0tza1JBvqr3bfAIFJGqfdRTyPae82+KTnm3coDXkZN9wnuW3HjGgN386D7hfv5CHQYCI022/rJPVlqXyHSw== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - string.prototype.trimstart "^1.0.0" - -string.prototype.trimright@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz#c76f1cef30f21bbad8afeb8db1511496cfb0f2a3" - integrity sha512-ZNRQ7sY3KroTaYjRS6EbNiiHrOkjihL9aQE/8gfQ4DtAC/aEBRHFJa44OmoWxGGqXuJlfKkZW4WcXErGr+9ZFg== +string.prototype.trimend@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" + integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== dependencies: define-properties "^1.1.3" es-abstract "^1.17.5" - string.prototype.trimend "^1.0.0" -string.prototype.trimstart@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.0.tgz#afe596a7ce9de905496919406c9734845f01a2f2" - integrity sha512-iCP8g01NFYiiBOnwG1Xc3WZLyoo+RuBymwIlWncShXDDJYWN6DbnM3odslBJdgCdRlq94B5s63NWAZlcn2CS4w== +string.prototype.trimstart@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" + integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== dependencies: define-properties "^1.1.3" es-abstract "^1.17.5" @@ -3562,11 +3542,6 @@ strip-bom@^3.0.0: resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= -strip-eof@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" - integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= - strip-json-comments@^3.0.1: version "3.1.0" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.0.tgz#7638d31422129ecf4457440009fba03f9f9ac180" @@ -3597,9 +3572,9 @@ supports-color@^7.1.0: has-flag "^4.0.0" swagger-ui-dist@^3.18.1: - version "3.25.1" - resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-3.25.1.tgz#8aa9c3217849722f6d8c7fac6b2222f9082227bb" - integrity sha512-Sw/K95j1pT9TZtLKiHDEml7YqcXC9thTTQjxrvNgd9j1KzOIxpo/5lhHuUMAN/hxVAHetzmcBcQaBjywRXog8w== + version "3.27.0" + resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-3.27.0.tgz#9d0ff14a96cd8ede12af521908299fa31f71ce2e" + integrity sha512-dlbH4L8+UslXVeYvCulicmJP2cnHLoabQGfeav5lx74fM+tMQW53M8iqpH5wbBqBbFkZwza+IIWoPrenqO/F2g== swagger-ui-express@^4.1.4: version "4.1.4" @@ -3642,12 +3617,10 @@ teeny-request@^6.0.0: stream-events "^1.0.5" uuid "^7.0.0" -term-size@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/term-size/-/term-size-1.2.0.tgz#458b83887f288fc56d6fffbfad262e26638efa69" - integrity sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk= - dependencies: - execa "^0.7.0" +term-size@^2.1.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/term-size/-/term-size-2.2.0.tgz#1f16adedfe9bdc18800e1776821734086fcc6753" + integrity sha512-a6sumDlzyHVJWb8+YofY4TW112G6p2FCPEAFk+59gIYHv3XHRhm9ltVQ9kli4hNWeQBwSpe8cRN25x0ROunMOw== text-table@^0.2.0: version "0.2.0" @@ -3674,11 +3647,6 @@ through@^2.3.6: resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= -timed-out@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" - integrity sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8= - tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -3691,6 +3659,11 @@ to-array@0.1.4: resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" integrity sha1-F+bBH3PdTz10zaek/zI46a2b+JA= +to-readable-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771" + integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q== + to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -3710,10 +3683,20 @@ touch@^3.1.0: dependencies: nopt "~1.0.10" -tslib@1.11.1, tslib@^1.9.0: - version "1.11.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35" - integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA== +tsconfig-paths@^3.9.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz#098547a6c4448807e8fcb8eae081064ee9a3c90b" + integrity sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw== + dependencies: + "@types/json5" "^0.0.29" + json5 "^1.0.1" + minimist "^1.2.0" + strip-bom "^3.0.0" + +tslib@^1.11.1, tslib@^1.9.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" + integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== type-check@~0.3.2: version "0.3.2" @@ -3759,13 +3742,6 @@ undefsafe@^2.0.2: dependencies: debug "^2.2.0" -unique-string@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" - integrity sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo= - dependencies: - crypto-random-string "^1.0.0" - unique-string@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-2.0.0.tgz#39c6451f81afb2749de2b233e3f7c5e8843bd89d" @@ -3778,26 +3754,24 @@ unpipe@1.0.0, unpipe@~1.0.0: resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= -unzip-response@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" - integrity sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c= - -update-notifier@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.5.0.tgz#d0744593e13f161e406acb1d9408b72cad08aff6" - integrity sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw== +update-notifier@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.0.tgz#4866b98c3bc5b5473c020b1250583628f9a328f3" + integrity sha512-w3doE1qtI0/ZmgeoDoARmI5fjDoT93IfKgEGqm26dGUOh8oNpaSTsGNdYRN/SjOuo10jcJGwkEL3mroKzktkew== dependencies: - boxen "^1.2.1" - chalk "^2.0.1" - configstore "^3.0.0" + boxen "^4.2.0" + chalk "^3.0.0" + configstore "^5.0.1" + has-yarn "^2.1.0" import-lazy "^2.1.0" - is-ci "^1.0.10" - is-installed-globally "^0.1.0" - is-npm "^1.0.0" - latest-version "^3.0.0" - semver-diff "^2.0.0" - xdg-basedir "^3.0.0" + is-ci "^2.0.0" + is-installed-globally "^0.3.1" + is-npm "^4.0.0" + is-yarn-global "^0.3.0" + latest-version "^5.0.0" + pupa "^2.0.1" + semver-diff "^3.1.1" + xdg-basedir "^4.0.0" uri-js@^4.2.2: version "4.2.2" @@ -3806,12 +3780,12 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -url-parse-lax@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" - integrity sha1-evjzA2Rem9eaJy56FKxovAYJ2nM= +url-parse-lax@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c" + integrity sha1-FrXK/Afb42dsGxmZF3gj1lA6yww= dependencies: - prepend-http "^1.0.1" + prepend-http "^2.0.0" util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" @@ -3829,9 +3803,9 @@ uuid@^7.0.0: integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg== v8-compile-cache@^2.0.3: - version "2.1.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e" - integrity sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g== + version "2.1.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz#54bc3cdd43317bca91e35dcaf305b1a7237de745" + integrity sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ== validate-npm-package-license@^3.0.1: version "3.0.4" @@ -3852,11 +3826,11 @@ walkdir@^0.4.0: integrity sha512-3eBwRyEln6E1MSzcxcVpQIhRG8Q1jLvEqRmCZqS3dsfXEDR/AhOF4d+jHg1qvDCpYaVRZjENPQyrVxAkQqxPgQ== websocket-driver@>=0.5.1: - version "0.7.3" - resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.3.tgz#a2d4e0d4f4f116f1e6297eba58b05d430100e9f9" - integrity sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg== + version "0.7.4" + resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" + integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== dependencies: - http-parser-js ">=0.4.0 <0.4.11" + http-parser-js ">=0.5.1" safe-buffer ">=5.1.0" websocket-extensions ">=0.1.1" @@ -3886,13 +3860,14 @@ which-collection@^1.0.1: is-weakmap "^2.0.1" is-weakset "^2.0.1" -which-typed-array@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.1.tgz#bff075fd975faedad9ed9355ee0d15452d068794" - integrity sha512-IWlkoJZ4Zdfi4YBn2wnYB8AVox+4A2+Kmr4kHFAraffHYrQZFiTOjgjk9et8e6RSPZOV1QjZOC51PVCK9SkR/A== +which-typed-array@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.2.tgz#e5f98e56bda93e3dac196b01d47c1156679c00b2" + integrity sha512-KT6okrd1tE6JdZAy3o2VhMoYPh3+J6EMZLyrxBQsZflI1QCZIxMrIYLkosd8Twf+YfknVIHmYQPgJt238p8dnQ== dependencies: - available-typed-arrays "^1.0.1" - es-abstract "^1.17.4" + available-typed-arrays "^1.0.2" + es-abstract "^1.17.5" + foreach "^2.0.5" function-bind "^1.1.1" has-symbols "^1.0.1" is-typed-array "^1.1.3" @@ -3911,12 +3886,12 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2 || 2" -widest-line@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-2.0.1.tgz#7438764730ec7ef4381ce4df82fb98a53142a3fc" - integrity sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA== +widest-line@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-3.1.0.tgz#8292333bbf66cb45ff0de1603b136b7ae1496eca" + integrity sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg== dependencies: - string-width "^2.1.1" + string-width "^4.0.0" word-wrap@~1.2.3: version "1.2.3" @@ -3928,15 +3903,6 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -write-file-atomic@^2.0.0: - version "2.4.3" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.3.tgz#1fd2e9ae1df3e75b8d8c367443c692d4ca81f481" - integrity sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ== - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - signal-exit "^3.0.2" - write-file-atomic@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.3.tgz#56bd5c5a5c70481cd19c571bd39ab965a5de56e8" @@ -3955,9 +3921,9 @@ write@1.0.3: mkdirp "^0.5.1" ws@^7.1.2: - version "7.2.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.3.tgz#a5411e1fb04d5ed0efee76d26d5c46d830c39b46" - integrity sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ== + version "7.3.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.0.tgz#4b2f7f219b3d3737bc1a2fbf145d825b94d38ffd" + integrity sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w== ws@~6.1.0: version "6.1.4" @@ -3966,11 +3932,6 @@ ws@~6.1.0: dependencies: async-limiter "~1.0.0" -xdg-basedir@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" - integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ= - xdg-basedir@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13" @@ -3986,11 +3947,6 @@ xtend@^4.0.1, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== -yallist@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= - yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" From 975fec21f6b1d7ac07e5e2c020ef873aea1a3b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A2maso=20J=C3=BAnio=20Pereira=20Brasileo?= Date: Mon, 22 Jun 2020 21:40:11 -0300 Subject: [PATCH 07/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ab7e0f7f..05109c3a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Para executar localmente a aplicação, proceda com os seguintes passos: 1. Instale o Docker [neste link](https://docs.docker.com/install/linux/docker-ce/ubuntu/). 2. Instale o Docker Compose [neste link](https://docs.docker.com/compose/install/). -3. Pegue o arquivo firebaseConfig.js do drive na pasta firebase e coloque-o dentro da pasta config do projeto. +3. Pegue o arquivo firebaseConfig.js e firebaseConfig-dev.js do drive na pasta firebase e coloque-o dentro da pasta config do projeto. 4. Crie um arquivo .env e dentro dele crie 2 váriaveis de ambiente LATITUDE_ENV= e LONGITUDE_ENV= 5. Coloque a latitude e longitude de sua casa nas variáveis de ambiente. 6. Na pasta principal do projeto, construa e inicialize a aplicação com o comando: `sudo docker-compose -f docker-compose.yml up --build`. From 7c0fd4983d6ffd6c99a42076c97c397bfa5f7e97 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Tue, 23 Jun 2020 18:07:04 -0300 Subject: [PATCH 08/28] Fix error with validation of category inside socket --- websocket.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/websocket.js b/websocket.js index a8b38706..a7a8ceb0 100644 --- a/websocket.js +++ b/websocket.js @@ -18,7 +18,6 @@ exports.setupWebsocket = (server) => { categories: [], }); - socket.on('change-locations', (locations) => { const index = connections.map((connection) => connection.id).indexOf(socket.id); if (index >= 0) { @@ -30,6 +29,9 @@ exports.setupWebsocket = (server) => { const index = connections.map((connection) => connection.id).indexOf(socket.id); if (index >= 0) { connections[index].categories = categories; + console.log('abacaxi'); + console.log(connections[index]); + console.log('--------------------------') } }); @@ -52,15 +54,25 @@ function canParse(locs) { } exports.findConnections = (coordinates, category, userId) => { const filtered = connections.filter((connection) => { + console.log(connection); if (userId === connection.userId) { return false; } + console.log(1); if (connection.categories && connection.categories.length) { const { categories } = connection; - if (!categories.includes(category)) { + let categoryExist = false; + for (let i = 0; i < categories.length; i = 1 + 1) { + if (categories[i] == category) { + categoryExist = true; + break; + } + } + if (!categoryExist) { return false; } } + console.log(4); let should = false; let locs = connection.locations; if (canParse(locs)) { From f0b898f285a7c936f7ddae872a0b91025a733a76 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Wed, 24 Jun 2020 10:41:03 -0300 Subject: [PATCH 09/28] Config of Sentry to track error/exception. Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- .gitignore | 1 + index.js | 5 ++ package.json | 1 + src/config/sentryConfig.js | 14 ++++ src/controllers/CategoryController.js | 2 +- src/models/ErrorHistory.js | 19 ----- src/repository/ErrorHistoryRepository.js | 21 ----- src/services/CategoryService.js | 2 +- src/services/ErrorHistoryService.js | 21 +++-- yarn.lock | 101 ++++++++++++++++++++++- 10 files changed, 136 insertions(+), 51 deletions(-) create mode 100644 src/config/sentryConfig.js delete mode 100644 src/models/ErrorHistory.js delete mode 100644 src/repository/ErrorHistoryRepository.js diff --git a/.gitignore b/.gitignore index 324cdaa8..c85afcaf 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ jspm_packages/ # Firebase config src/config/firebaseConfig.js +src/config/firebaseConfig-dev.js # Snowpack dependency directory (https://snowpack.dev/) web_modules/ diff --git a/index.js b/index.js index 9a492141..e29c7bfa 100644 --- a/index.js +++ b/index.js @@ -4,11 +4,14 @@ const bodyParser = require('body-parser'); const cors = require('cors'); const express = require('express'); const http = require('http'); +const Sentry = require('@sentry/node'); +const sentryInit = require('./src/config/sentryConfig'); const setRoutes = require('./src/routes/BaseRoutes'); const dailySchedule = require('./src/utils/schedule'); const { setupWebsocket } = require('./websocket'); const app = express(); +sentryInit(); const server = http.Server(app); app.use(express.json({ limit: '50mb' })); @@ -24,4 +27,6 @@ databaseConnect(); dailySchedule(); setRoutes(app); +app.use(Sentry.Handlers.errorHandler()); + server.listen(8000); diff --git a/package.json b/package.json index 47b5548b..1360e678 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "dev": "node server.js" }, "dependencies": { + "@sentry/node": "5.18.0", "bcrypt": "^4.0.1", "body-parser": "^1.19.0", "cors": "^2.8.5", diff --git a/src/config/sentryConfig.js b/src/config/sentryConfig.js new file mode 100644 index 00000000..d5287906 --- /dev/null +++ b/src/config/sentryConfig.js @@ -0,0 +1,14 @@ +const Sentry = require('@sentry/node'); + +const sentryInit = async () => { + const sentryDSN = process.env.SENTRY_DSN || null; + if (sentryDSN === null) { + console.log('Sentry não configurado. Os logs de erros não serão salvos na núvem.'); + } else { + Sentry.init({ + dsn: sentryDSN, + }); + } +}; + +module.exports = sentryInit; diff --git a/src/controllers/CategoryController.js b/src/controllers/CategoryController.js index 503b13e2..574c9f09 100644 --- a/src/controllers/CategoryController.js +++ b/src/controllers/CategoryController.js @@ -13,7 +13,7 @@ class CategoryController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.jsonError }); next(); } } diff --git a/src/models/ErrorHistory.js b/src/models/ErrorHistory.js deleted file mode 100644 index 4a5d4ca4..00000000 --- a/src/models/ErrorHistory.js +++ /dev/null @@ -1,19 +0,0 @@ -const mongoose = require('mongoose'); - -const errorHistorySchema = new mongoose.Schema({ - code: { - type: Number, - required: true, - }, - message: { - type: String, - required: true, - }, - registerDate: { - type: Date, - required: true, - default: Date.now, - }, -}, { collection: 'errorHistory' }); - -module.exports = mongoose.model('ErrorHistory', errorHistorySchema); diff --git a/src/repository/ErrorHistoryRepository.js b/src/repository/ErrorHistoryRepository.js deleted file mode 100644 index 58992bfd..00000000 --- a/src/repository/ErrorHistoryRepository.js +++ /dev/null @@ -1,21 +0,0 @@ -const BaseRepository = require('./BaseRepository'); -const ErrorHistory = require('../models/ErrorHistory'); - -class ErrorHistoryRepository extends BaseRepository { - constructor() { - super(ErrorHistory); - } - - async create(msg, code) { - const data = { - code, - message: msg, - }; - const result = await super.$save(data); - if (!result) { - throw new Error(); - } - } -} - -module.exports = ErrorHistoryRepository; diff --git a/src/services/CategoryService.js b/src/services/CategoryService.js index 1d1625a1..c65e18b5 100644 --- a/src/services/CategoryService.js +++ b/src/services/CategoryService.js @@ -1,5 +1,5 @@ const CategoryRepository = require('../repository/CategoryRepository'); - +const ErrorHistoryService = require('./ErrorHistoryService'); class CategoryService { constructor() { this.CategoryRepository = new CategoryRepository(); diff --git a/src/services/ErrorHistoryService.js b/src/services/ErrorHistoryService.js index e7b579df..93ec89dd 100644 --- a/src/services/ErrorHistoryService.js +++ b/src/services/ErrorHistoryService.js @@ -1,19 +1,26 @@ -const ErrorHistoryRepository = require('../repository/ErrorHistoryRepository'); +const Sentry = require('@sentry/node'); -const ErrorHistoryRepository2 = new ErrorHistoryRepository(); class ErrorHistoryService extends Error { - constructor(message, code) { + constructor(message) { super(message); - this.msg = message; - this.code = code; + console.log(this); + this.jsonError = this.showError(); this.saveError(); } + showError() { + const errorMessage = { + message: this.message, + }; + + return errorMessage; + } + saveError() { try { - ErrorHistoryRepository2.create(this.msg, this.code); + Sentry.captureException(this); } catch (err) { - console.log('Não foi possível salvar o erro'); + console.log('Não foi possível salvar o erro!'); console.log(err); } } diff --git a/yarn.lock b/yarn.lock index a3b1a86a..0f4f2401 100644 --- a/yarn.lock +++ b/yarn.lock @@ -253,6 +253,85 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= +"@sentry/apm@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@sentry/apm/-/apm-5.18.0.tgz#344d672898c80d8768525e87b1e79c9a51b8e95c" + integrity sha512-KGxpfAwSIXlHnGBR1OSj4haAuk6xNV8b1gx2q6ZR3r3u3xLcoUlgASEDAFM82fFDJxZxu/ygf8mmuJNKos2EZg== + dependencies: + "@sentry/browser" "5.18.0" + "@sentry/hub" "5.18.0" + "@sentry/minimal" "5.18.0" + "@sentry/types" "5.18.0" + "@sentry/utils" "5.18.0" + tslib "^1.9.3" + +"@sentry/browser@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.18.0.tgz#eaf121d024d1eac2db76a6b3dabd9d4ff38637e8" + integrity sha512-YJTytTFyE68KyTiQZ+mMPFOU4EzWQwjk4k6DtBCFnJeX74iIAoM1o2uBHMIf9RnY+gmcykblC+nhkkRIXB6Zmg== + dependencies: + "@sentry/core" "5.18.0" + "@sentry/types" "5.18.0" + "@sentry/utils" "5.18.0" + tslib "^1.9.3" + +"@sentry/core@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.18.0.tgz#9b652df59df3b6521a54f7c77892607d02f93275" + integrity sha512-juZqflnuyjziMWX+JUIUa0ouXQn/Mfjcw3RvvOknKCWVvDZVaEeO/YPByYPO+SGYnzBhwZOzJC+vW6UZVi2b6w== + dependencies: + "@sentry/hub" "5.18.0" + "@sentry/minimal" "5.18.0" + "@sentry/types" "5.18.0" + "@sentry/utils" "5.18.0" + tslib "^1.9.3" + +"@sentry/hub@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.18.0.tgz#ba3dd893e7ba1736557c6bd63eb1762d49b326e1" + integrity sha512-z/ES63weTUJxezqWPxkLc+XuTkPsMcaaGc/d5MYNbsalVfMSR3K6bOOTv6Gow5bbrqYpRoPr+4+On8wPShdw+A== + dependencies: + "@sentry/types" "5.18.0" + "@sentry/utils" "5.18.0" + tslib "^1.9.3" + +"@sentry/minimal@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.18.0.tgz#2eafed4784c8d6e30ec21aea885183e5bf1b0279" + integrity sha512-mNiqVD8yvQY1Xu205dMjiXJ4DX67XVYMZkX1JRBP0wc5nnreQVeptlFiZeJ44UGTBEFpaXVATodK6jDRvgDI9A== + dependencies: + "@sentry/hub" "5.18.0" + "@sentry/types" "5.18.0" + tslib "^1.9.3" + +"@sentry/node@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.18.0.tgz#e7a2a1f9f4959b7e2ee6d39cd68e1ec05430aa51" + integrity sha512-dDwnTaXO9ZP9IwjKSxFbpVucszaNLzqk++J+RhAhYsfO+KdIoMk3CyQ1aLfQRAkD9W/JipLlkRzzSOSzS6HQLA== + dependencies: + "@sentry/apm" "5.18.0" + "@sentry/core" "5.18.0" + "@sentry/hub" "5.18.0" + "@sentry/types" "5.18.0" + "@sentry/utils" "5.18.0" + cookie "^0.3.1" + https-proxy-agent "^4.0.0" + lru_map "^0.3.3" + tslib "^1.9.3" + +"@sentry/types@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.18.0.tgz#8ae1f08a2b8887cccd3a28c0a88e3add1bb5d3ec" + integrity sha512-5zqgN9qkbDqjyFxeiP7g55zAugRXPzmAwaz+WXCv0EJfb8aVf5iiD7SfgO++pwS8BPH3EH9d4zHWAKI8mM6ZcQ== + +"@sentry/utils@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.18.0.tgz#aec46d2155d71ea857c3c55a090a93b08b3ce076" + integrity sha512-HN12MMg41ug/mH/QftHH2DbuzWE7GZts1AoStGjCzn0deDXGv7KnKMr1fasVxGRwS64+aTWMYQCMWyNWPsoqjg== + dependencies: + "@sentry/types" "5.18.0" + tslib "^1.9.3" + "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" @@ -342,6 +421,11 @@ after@0.8.2: resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" integrity sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8= +agent-base@5: + version "5.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-5.1.1.tgz#e8fb3f242959db44d63be665db7a8e739537a32c" + integrity sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g== + agent-base@6: version "6.0.0" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.0.tgz#5d0101f19bbfaed39980b22ae866de153b93f09a" @@ -837,7 +921,7 @@ cookie-signature@1.0.6: resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw= -cookie@0.3.1: +cookie@0.3.1, cookie@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s= @@ -1833,6 +1917,14 @@ http-proxy-agent@^4.0.0: agent-base "6" debug "4" +https-proxy-agent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz#702b71fb5520a132a66de1f67541d9e62154d82b" + integrity sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg== + dependencies: + agent-base "5" + debug "4" + https-proxy-agent@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2" @@ -2356,6 +2448,11 @@ lru-cache@^5.0.0: dependencies: yallist "^3.0.2" +lru_map@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd" + integrity sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0= + make-dir@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" @@ -3693,7 +3790,7 @@ tsconfig-paths@^3.9.0: minimist "^1.2.0" strip-bom "^3.0.0" -tslib@^1.11.1, tslib@^1.9.0: +tslib@^1.11.1, tslib@^1.9.0, tslib@^1.9.3: version "1.13.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== From 94c5f99c89e7a91d66447db56c700cd51c5dfa2b Mon Sep 17 00:00:00 2001 From: darmsDD Date: Wed, 24 Jun 2020 11:04:48 -0300 Subject: [PATCH 10/28] Fix error/exception return in category. Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- src/controllers/CategoryController.js | 4 ++-- src/services/CategoryService.js | 6 ++++-- src/services/ErrorHistoryService.js | 9 --------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/controllers/CategoryController.js b/src/controllers/CategoryController.js index 574c9f09..364c813a 100644 --- a/src/controllers/CategoryController.js +++ b/src/controllers/CategoryController.js @@ -13,7 +13,7 @@ class CategoryController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err.jsonError }); + res.status(400).json({ error: err.message }); next(); } } @@ -26,7 +26,7 @@ class CategoryController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); next(); } } diff --git a/src/services/CategoryService.js b/src/services/CategoryService.js index c65e18b5..98955b5f 100644 --- a/src/services/CategoryService.js +++ b/src/services/CategoryService.js @@ -1,15 +1,17 @@ const CategoryRepository = require('../repository/CategoryRepository'); const ErrorHistoryService = require('./ErrorHistoryService'); + class CategoryService { constructor() { this.CategoryRepository = new CategoryRepository(); } + // TODO: Querys parecem idênticas async getCategoryByid(id) { const Category = await this.CategoryRepository.getById(id); if (!Category) { - throw 'Categoria não encontrada'; + throw new ErrorHistoryService('Categoria não encontrada'); } return Category; @@ -18,7 +20,7 @@ class CategoryService { async getCategoryList(id) { const Categorylist = await this.CategoryRepository.list(id); if (!Categorylist) { - throw 'Categorias não encontrada'; + throw new ErrorHistoryService('Categoria não encontrada'); } return Categorylist; diff --git a/src/services/ErrorHistoryService.js b/src/services/ErrorHistoryService.js index 93ec89dd..258c91d7 100644 --- a/src/services/ErrorHistoryService.js +++ b/src/services/ErrorHistoryService.js @@ -4,18 +4,9 @@ class ErrorHistoryService extends Error { constructor(message) { super(message); console.log(this); - this.jsonError = this.showError(); this.saveError(); } - showError() { - const errorMessage = { - message: this.message, - }; - - return errorMessage; - } - saveError() { try { Sentry.captureException(this); From 10bfb700b1fe56f775b458bd5aa81265dc8ec69e Mon Sep 17 00:00:00 2001 From: darmsDD Date: Wed, 24 Jun 2020 11:25:57 -0300 Subject: [PATCH 11/28] Fix error/exception return in help. Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- src/controllers/HelpController.js | 22 +++++++-------- src/repository/HelpRepository.js | 32 ++++++++++------------ src/services/HelpService.js | 45 +++++++++++++++---------------- 3 files changed, 46 insertions(+), 53 deletions(-) diff --git a/src/controllers/HelpController.js b/src/controllers/HelpController.js index 969f9653..855a211e 100644 --- a/src/controllers/HelpController.js +++ b/src/controllers/HelpController.js @@ -17,7 +17,7 @@ class HelpController { res.status(201).json(result); next(); } catch (err) { - res.status(400).send({ error: err }); + res.status(400).send({ error: err.message }); next(); } } @@ -30,7 +30,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); next(); } } @@ -70,7 +70,7 @@ class HelpController { res.json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); next(); } } @@ -92,7 +92,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); next(); } } @@ -105,7 +105,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); next(); } } @@ -118,7 +118,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); next(); } } @@ -131,7 +131,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); next(); } } @@ -144,7 +144,7 @@ class HelpController { res.status(204).json(); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); } } @@ -157,7 +157,7 @@ class HelpController { res.status(204).json(); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); next(); } } @@ -169,12 +169,10 @@ class HelpController { res.json(result); next(); } catch (err) { - res.status(400); - res.json(err); + res.status(400).json({ error: err.message }); next(); } } } - module.exports = HelpController; diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index 4b8f7995..d1ccc921 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -276,26 +276,22 @@ class HelpRepository extends BaseRepository { }, ]; - try { - const helps = await super.$listAggregate(aggregation); - const helpsWithDistance = helps.map((help) => { - const coordinates = { - latitude: coords[1], - longitude: coords[0], - }; - const helpCoords = { - latitude: help.user.location.coordinates[1], - longitude: help.user.location.coordinates[0], - }; - help.distance = getDistance(coordinates, helpCoords); + const helps = await super.$listAggregate(aggregation); + const helpsWithDistance = helps.map((help) => { + const coordinates = { + latitude: coords[1], + longitude: coords[0], + }; + const helpCoords = { + latitude: help.user.location.coordinates[1], + longitude: help.user.location.coordinates[0], + }; + help.distance = getDistance(coordinates, helpCoords); - return help; - }); + return help; + }); - return helpsWithDistance; - } catch (error) { - throw error; - } + return helpsWithDistance; } async countDocuments(id) { diff --git a/src/services/HelpService.js b/src/services/HelpService.js index f1dbf030..1f61c9cd 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -6,7 +6,7 @@ const CategoryService = require('./CategoryService'); const { findConnections, sendMessage } = require('../../websocket'); const NotificationMixin = require('../utils/NotificationMixin'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); - +const ErrorHistoryService = require('./ErrorHistoryService'); class HelpService { constructor() { @@ -20,7 +20,7 @@ class HelpService { async createHelp(data) { const countHelp = await this.HelpRepository.countDocuments(data.ownerId); if (countHelp >= 5) { - throw 'Limite máximo de pedidos atingido'; + throw new ErrorHistoryService('Limite máximo de pedidos atingido'); } await this.CategoryService.getCategoryByid(data.categoryId); @@ -46,7 +46,7 @@ class HelpService { const Help = await this.HelpRepository.getById(id); if (!Help) { - throw 'Ajuda não encontrada'; + throw new ErrorHistoryService('Ajuda não encontrada'); } return Help; @@ -62,7 +62,7 @@ class HelpService { helper, ); if (!Helplist) { - throw 'Nenhuma Ajuda com esse status foi encontrada'; + throw new ErrorHistoryService('Nenhuma Ajuda com esse status foi encontrada'); } return Helplist; @@ -76,7 +76,7 @@ class HelpService { categoryArray, ); if (!Helplist) { - throw 'Pedidos de ajuda não encontrados no seu raio de distância'; + throw new ErrorHistoryService('Pedidos de ajuda não encontrados no seu raio de distância'); } return Helplist; @@ -105,7 +105,7 @@ class HelpService { const checkHelpStatusExistence = statusList.filter((item) => !Object.values(helpStatusEnum).includes(item)); if (checkHelpStatusExistence.length > 0) { - throw 'Um dos status informados é ínvalido.'; + throw new ErrorHistoryService('Um dos status informados é ínvalido.'); } const helpList = await this.HelpRepository.getHelpListByStatus(userId, statusList, helper); @@ -121,13 +121,12 @@ class HelpService { const helper = await this.UserService.getUser({ id: idHelper }); const owner = await this.UserService.getUser({ id: ownerId }); if (!help) { - throw 'Ajuda não encontrada'; + throw new ErrorHistoryService('Ajuda não encontrada'); } if (help.helperId) { - throw 'Ajuda já possui ajudante'; + throw new ErrorHistoryService('Ajuda já possui ajudante'); } - const ownerCoords = { longitude: owner.location.coordinates[0], latitude: owner.location.coordinates[1], @@ -166,7 +165,7 @@ class HelpService { } return result; } - throw 'Ajudante não encontrado'; + throw new ErrorHistoryService('Ajudante não encontrado'); } async helperConfirmation(data) { @@ -175,9 +174,9 @@ class HelpService { const helper = await this.UserService.getUser({ id: help.helperId }); if (!help) { - throw 'Ajuda não encontrada'; + throw new ErrorHistoryService('Ajuda não encontrada'); } else if (help.helperId != data.helperId) { - throw 'Usuário não é o ajudante dessa ajuda'; + throw new ErrorHistoryService('Usuário não é o ajudante dessa ajuda'); } else if (help.status === 'owner_finished') { const ownerTitle = 'Pedido de ajuda finalizado!'; const ownerBody = `Seu pedido ${help.title} foi finalizado`; @@ -211,9 +210,9 @@ class HelpService { help.status = 'finished'; } else if (help.status === 'helper_finished') { - throw 'Usuário já confirmou a finalização da ajuda'; + throw new ErrorHistoryService('Usuário já confirmou a finalização da ajuda'); } else if (help.status === 'finished') { - throw 'Ajuda já foi finalizada'; + throw new ErrorHistoryService('Ajuda já foi finalizada'); } else { help.status = 'helper_finished'; } @@ -229,9 +228,9 @@ class HelpService { const helper = await this.UserService.getUser({ id: help.helperId }); if (!help) { - throw 'Ajuda não encontrada'; + throw new ErrorHistoryService('Ajuda não encontrada'); } else if (help.ownerId != data.ownerId) { - throw 'Usuário não é o dono da ajuda'; + throw new ErrorHistoryService('Usuário não é o dono da ajuda'); } else if (help.status === 'helper_finished') { const ownerTitle = 'Pedido de ajuda finalizado!'; const ownerBody = `Seu pedido ${help.title} foi finalizado`; @@ -265,9 +264,9 @@ class HelpService { help.status = 'finished'; } else if (help.status === 'owner_finished') { - throw 'Usuário já confirmou a finalização da ajuda'; + throw new ErrorHistoryService('Usuário já confirmou a finalização da ajuda'); } else if (help.status === 'finished') { - throw 'Essa ajuda já foi finalizada'; + throw new ErrorHistoryService('Essa ajuda já foi finalizada'); } else { help.status = 'owner_finished'; } @@ -280,21 +279,21 @@ class HelpService { const help = await this.getHelpByid(id); const owner = await this.UserService.getUser({ id: help.ownerId }); if (!help) { - throw 'Ajuda não encontrada'; + throw new ErrorHistoryService('Ajuda não encontrada'); } if (idHelper == help.ownerId) { - throw 'Você não pode ser ajudante de sua própria ajuda'; + throw new ErrorHistoryService('Você não pode ser ajudante de sua própria ajuda'); } if (help.helperId) { - throw 'Ajuda já possui ajudante'; + throw new ErrorHistoryService('Ajuda já possui ajudante'); } const helper = await this.UserService.getUser({ id: idHelper }); const userPosition = help.possibleHelpers.indexOf(idHelper); if (userPosition > -1) { - throw 'Usuário já é um possível ajudante'; + throw new ErrorHistoryService('Usuário já é um possível ajudante'); } help.possibleHelpers.push(idHelper); @@ -325,7 +324,7 @@ class HelpService { async getListToDelete() { const Helplist = await this.HelpRepository.listToExpire(); if (!Helplist) { - throw new Error('Pedidos de ajuda não encontrados'); + throw new ErrorHistoryService('Pedidos de ajuda não encontrados'); } return Helplist; From 2dd367e27b94a8b6451275b8fa840f98e6b7fd81 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Wed, 24 Jun 2020 12:07:00 -0300 Subject: [PATCH 12/28] Save error/exception in category controller. Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- src/controllers/CategoryController.js | 7 +++- src/controllers/NotificationController.js | 2 +- src/services/CategoryService.js | 6 +-- src/services/ErrorHistoryService.js | 11 +++--- src/services/HelpService.js | 47 +++++++++++------------ 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/controllers/CategoryController.js b/src/controllers/CategoryController.js index 364c813a..50f05e8d 100644 --- a/src/controllers/CategoryController.js +++ b/src/controllers/CategoryController.js @@ -1,4 +1,5 @@ const CategoryService = require('../services/CategoryService'); +const ErrorHistoryService = require('../services/ErrorHistoryService'); class CategoryController { constructor() { @@ -13,7 +14,8 @@ class CategoryController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err.message }); + const savedError = new ErrorHistoryService(err); + res.status(400).json({ error: savedError.message }); next(); } } @@ -26,7 +28,8 @@ class CategoryController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err.message }); + const savedError = new ErrorHistoryService(err); + res.status(400).json({ error: savedError.message }); next(); } } diff --git a/src/controllers/NotificationController.js b/src/controllers/NotificationController.js index ae0c08f7..638f8813 100644 --- a/src/controllers/NotificationController.js +++ b/src/controllers/NotificationController.js @@ -13,7 +13,7 @@ class NotificationController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + res.status(400).json({ error: err.message }); next(); } } diff --git a/src/services/CategoryService.js b/src/services/CategoryService.js index 98955b5f..a94e479b 100644 --- a/src/services/CategoryService.js +++ b/src/services/CategoryService.js @@ -1,5 +1,5 @@ const CategoryRepository = require('../repository/CategoryRepository'); -const ErrorHistoryService = require('./ErrorHistoryService'); + class CategoryService { constructor() { @@ -11,7 +11,7 @@ class CategoryService { const Category = await this.CategoryRepository.getById(id); if (!Category) { - throw new ErrorHistoryService('Categoria não encontrada'); + throw new Error('Categoria não encontrada'); } return Category; @@ -20,7 +20,7 @@ class CategoryService { async getCategoryList(id) { const Categorylist = await this.CategoryRepository.list(id); if (!Categorylist) { - throw new ErrorHistoryService('Categoria não encontrada'); + throw new Error('Categoria não encontrada'); } return Categorylist; diff --git a/src/services/ErrorHistoryService.js b/src/services/ErrorHistoryService.js index 258c91d7..4ea1d2ca 100644 --- a/src/services/ErrorHistoryService.js +++ b/src/services/ErrorHistoryService.js @@ -1,15 +1,16 @@ const Sentry = require('@sentry/node'); -class ErrorHistoryService extends Error { - constructor(message) { - super(message); - console.log(this); +class ErrorHistoryService { + constructor(err) { + console.log(err); + this.err = err; + this.message = err.message; this.saveError(); } saveError() { try { - Sentry.captureException(this); + Sentry.captureException(this.err); } catch (err) { console.log('Não foi possível salvar o erro!'); console.log(err); diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 1f61c9cd..f505099d 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -6,7 +6,7 @@ const CategoryService = require('./CategoryService'); const { findConnections, sendMessage } = require('../../websocket'); const NotificationMixin = require('../utils/NotificationMixin'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); -const ErrorHistoryService = require('./ErrorHistoryService'); + class HelpService { constructor() { @@ -20,7 +20,7 @@ class HelpService { async createHelp(data) { const countHelp = await this.HelpRepository.countDocuments(data.ownerId); if (countHelp >= 5) { - throw new ErrorHistoryService('Limite máximo de pedidos atingido'); + throw new Error('Limite máximo de pedidos atingido'); } await this.CategoryService.getCategoryByid(data.categoryId); @@ -46,13 +46,12 @@ class HelpService { const Help = await this.HelpRepository.getById(id); if (!Help) { - throw new ErrorHistoryService('Ajuda não encontrada'); + throw new Error('Ajuda não encontrada'); } return Help; } - async getHelpList(id, status, category, except, helper) { const Helplist = await this.HelpRepository.list( id, @@ -62,7 +61,7 @@ class HelpService { helper, ); if (!Helplist) { - throw new ErrorHistoryService('Nenhuma Ajuda com esse status foi encontrada'); + throw new Error('Nenhuma Ajuda com esse status foi encontrada'); } return Helplist; @@ -76,7 +75,7 @@ class HelpService { categoryArray, ); if (!Helplist) { - throw new ErrorHistoryService('Pedidos de ajuda não encontrados no seu raio de distância'); + throw new Error('Pedidos de ajuda não encontrados no seu raio de distância'); } return Helplist; @@ -105,7 +104,7 @@ class HelpService { const checkHelpStatusExistence = statusList.filter((item) => !Object.values(helpStatusEnum).includes(item)); if (checkHelpStatusExistence.length > 0) { - throw new ErrorHistoryService('Um dos status informados é ínvalido.'); + throw new Error('Um dos status informados é ínvalido.'); } const helpList = await this.HelpRepository.getHelpListByStatus(userId, statusList, helper); @@ -113,7 +112,6 @@ class HelpService { return helpList; } - async chooseHelper(data) { const { idHelper } = data; const help = await this.getHelpByid(data.idHelp); @@ -121,10 +119,10 @@ class HelpService { const helper = await this.UserService.getUser({ id: idHelper }); const owner = await this.UserService.getUser({ id: ownerId }); if (!help) { - throw new ErrorHistoryService('Ajuda não encontrada'); + throw new Error('Ajuda não encontrada'); } if (help.helperId) { - throw new ErrorHistoryService('Ajuda já possui ajudante'); + throw new Error('Ajuda já possui ajudante'); } const ownerCoords = { @@ -138,7 +136,6 @@ class HelpService { ); sendMessage(sendSocketMessageTo, 'delete-help', help._id); - const title = `${owner.name} aceitou sua oferta de ajuda!`; const body = `Sua oferta para ${help.title} foi aceita`; @@ -165,7 +162,7 @@ class HelpService { } return result; } - throw new ErrorHistoryService('Ajudante não encontrado'); + throw new Error('Ajudante não encontrado'); } async helperConfirmation(data) { @@ -174,9 +171,9 @@ class HelpService { const helper = await this.UserService.getUser({ id: help.helperId }); if (!help) { - throw new ErrorHistoryService('Ajuda não encontrada'); + throw new Error('Ajuda não encontrada'); } else if (help.helperId != data.helperId) { - throw new ErrorHistoryService('Usuário não é o ajudante dessa ajuda'); + throw new Error('Usuário não é o ajudante dessa ajuda'); } else if (help.status === 'owner_finished') { const ownerTitle = 'Pedido de ajuda finalizado!'; const ownerBody = `Seu pedido ${help.title} foi finalizado`; @@ -210,9 +207,9 @@ class HelpService { help.status = 'finished'; } else if (help.status === 'helper_finished') { - throw new ErrorHistoryService('Usuário já confirmou a finalização da ajuda'); + throw new Error('Usuário já confirmou a finalização da ajuda'); } else if (help.status === 'finished') { - throw new ErrorHistoryService('Ajuda já foi finalizada'); + throw new Error('Ajuda já foi finalizada'); } else { help.status = 'helper_finished'; } @@ -228,9 +225,9 @@ class HelpService { const helper = await this.UserService.getUser({ id: help.helperId }); if (!help) { - throw new ErrorHistoryService('Ajuda não encontrada'); + throw new Error('Ajuda não encontrada'); } else if (help.ownerId != data.ownerId) { - throw new ErrorHistoryService('Usuário não é o dono da ajuda'); + throw new Error('Usuário não é o dono da ajuda'); } else if (help.status === 'helper_finished') { const ownerTitle = 'Pedido de ajuda finalizado!'; const ownerBody = `Seu pedido ${help.title} foi finalizado`; @@ -264,9 +261,9 @@ class HelpService { help.status = 'finished'; } else if (help.status === 'owner_finished') { - throw new ErrorHistoryService('Usuário já confirmou a finalização da ajuda'); + throw new Error('Usuário já confirmou a finalização da ajuda'); } else if (help.status === 'finished') { - throw new ErrorHistoryService('Essa ajuda já foi finalizada'); + throw new Error('Essa ajuda já foi finalizada'); } else { help.status = 'owner_finished'; } @@ -279,21 +276,21 @@ class HelpService { const help = await this.getHelpByid(id); const owner = await this.UserService.getUser({ id: help.ownerId }); if (!help) { - throw new ErrorHistoryService('Ajuda não encontrada'); + throw new Error('Ajuda não encontrada'); } if (idHelper == help.ownerId) { - throw new ErrorHistoryService('Você não pode ser ajudante de sua própria ajuda'); + throw new Error('Você não pode ser ajudante de sua própria ajuda'); } if (help.helperId) { - throw new ErrorHistoryService('Ajuda já possui ajudante'); + throw new Error('Ajuda já possui ajudante'); } const helper = await this.UserService.getUser({ id: idHelper }); const userPosition = help.possibleHelpers.indexOf(idHelper); if (userPosition > -1) { - throw new ErrorHistoryService('Usuário já é um possível ajudante'); + throw new Error('Usuário já é um possível ajudante'); } help.possibleHelpers.push(idHelper); @@ -324,7 +321,7 @@ class HelpService { async getListToDelete() { const Helplist = await this.HelpRepository.listToExpire(); if (!Helplist) { - throw new ErrorHistoryService('Pedidos de ajuda não encontrados'); + throw new Error('Pedidos de ajuda não encontrados'); } return Helplist; From 7f6fc996bc164a439130c6671cf7031a8065319a Mon Sep 17 00:00:00 2001 From: darmsDD Date: Wed, 24 Jun 2020 19:44:12 -0300 Subject: [PATCH 13/28] Fix error in increment --- websocket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket.js b/websocket.js index a7a8ceb0..e7a75561 100644 --- a/websocket.js +++ b/websocket.js @@ -62,7 +62,7 @@ exports.findConnections = (coordinates, category, userId) => { if (connection.categories && connection.categories.length) { const { categories } = connection; let categoryExist = false; - for (let i = 0; i < categories.length; i = 1 + 1) { + for (let i = 0; i < categories.length; i += 1) { if (categories[i] == category) { categoryExist = true; break; From 9d278540229e17b74d0161925e079f2b1ef79a11 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Thu, 25 Jun 2020 10:19:30 -0300 Subject: [PATCH 14/28] Remove console.log --- websocket.js | 1 - 1 file changed, 1 deletion(-) diff --git a/websocket.js b/websocket.js index e7a75561..24520d5a 100644 --- a/websocket.js +++ b/websocket.js @@ -54,7 +54,6 @@ function canParse(locs) { } exports.findConnections = (coordinates, category, userId) => { const filtered = connections.filter((connection) => { - console.log(connection); if (userId === connection.userId) { return false; } From ea4cc208cfcac65e1bbe6ccd98deb947a1c2dc35 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Thu, 25 Jun 2020 10:27:21 -0300 Subject: [PATCH 15/28] Remove console.log --- websocket.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/websocket.js b/websocket.js index 24520d5a..cbabb6bb 100644 --- a/websocket.js +++ b/websocket.js @@ -29,9 +29,6 @@ exports.setupWebsocket = (server) => { const index = connections.map((connection) => connection.id).indexOf(socket.id); if (index >= 0) { connections[index].categories = categories; - console.log('abacaxi'); - console.log(connections[index]); - console.log('--------------------------') } }); @@ -57,7 +54,6 @@ exports.findConnections = (coordinates, category, userId) => { if (userId === connection.userId) { return false; } - console.log(1); if (connection.categories && connection.categories.length) { const { categories } = connection; let categoryExist = false; @@ -71,7 +67,6 @@ exports.findConnections = (coordinates, category, userId) => { return false; } } - console.log(4); let should = false; let locs = connection.locations; if (canParse(locs)) { From 265549ef943474971e61f665aef6c19da0a82f6c Mon Sep 17 00:00:00 2001 From: darmsDD Date: Thu, 25 Jun 2020 19:42:11 -0300 Subject: [PATCH 16/28] Save error in Help. Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- src/controllers/CategoryController.js | 10 +++++----- src/controllers/HelpController.js | 11 +++++++++++ src/services/CategoryService.js | 1 - src/services/ErrorHistoryService.js | 21 --------------------- src/services/HelpService.js | 8 ++++++-- src/utils/ErrorHistory.js | 13 +++++++++++++ src/utils/NotificationMixin.js | 6 +----- 7 files changed, 36 insertions(+), 34 deletions(-) delete mode 100644 src/services/ErrorHistoryService.js create mode 100644 src/utils/ErrorHistory.js diff --git a/src/controllers/CategoryController.js b/src/controllers/CategoryController.js index 50f05e8d..2c78a30a 100644 --- a/src/controllers/CategoryController.js +++ b/src/controllers/CategoryController.js @@ -1,5 +1,5 @@ const CategoryService = require('../services/CategoryService'); -const ErrorHistoryService = require('../services/ErrorHistoryService'); +const saveError = require('../utils/ErrorHistory'); class CategoryController { constructor() { @@ -14,8 +14,8 @@ class CategoryController { res.status(200).json(result); next(); } catch (err) { - const savedError = new ErrorHistoryService(err); - res.status(400).json({ error: savedError.message }); + saveError(err); + res.status(400).json({ error: err.message }); next(); } } @@ -28,8 +28,8 @@ class CategoryController { res.status(200).json(result); next(); } catch (err) { - const savedError = new ErrorHistoryService(err); - res.status(400).json({ error: savedError.message }); + saveError(err); + res.status(400).json({ error: err.message }); next(); } } diff --git a/src/controllers/HelpController.js b/src/controllers/HelpController.js index 855a211e..c33ae77a 100644 --- a/src/controllers/HelpController.js +++ b/src/controllers/HelpController.js @@ -1,5 +1,6 @@ const HelpService = require('../services/HelpService'); const UserService = require('../services/UserService'); +const saveError = require('../utils/ErrorHistory'); class HelpController { constructor() { @@ -17,6 +18,7 @@ class HelpController { res.status(201).json(result); next(); } catch (err) { + saveError(err); res.status(400).send({ error: err.message }); next(); } @@ -30,6 +32,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); next(); } @@ -70,6 +73,7 @@ class HelpController { res.json(result); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); next(); } @@ -92,6 +96,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); next(); } @@ -105,6 +110,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); next(); } @@ -118,6 +124,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); next(); } @@ -131,6 +138,7 @@ class HelpController { res.status(200).json(result); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); next(); } @@ -144,6 +152,7 @@ class HelpController { res.status(204).json(); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); } } @@ -157,6 +166,7 @@ class HelpController { res.status(204).json(); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); next(); } @@ -169,6 +179,7 @@ class HelpController { res.json(result); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); next(); } diff --git a/src/services/CategoryService.js b/src/services/CategoryService.js index a94e479b..d0251697 100644 --- a/src/services/CategoryService.js +++ b/src/services/CategoryService.js @@ -1,6 +1,5 @@ const CategoryRepository = require('../repository/CategoryRepository'); - class CategoryService { constructor() { this.CategoryRepository = new CategoryRepository(); diff --git a/src/services/ErrorHistoryService.js b/src/services/ErrorHistoryService.js deleted file mode 100644 index 4ea1d2ca..00000000 --- a/src/services/ErrorHistoryService.js +++ /dev/null @@ -1,21 +0,0 @@ -const Sentry = require('@sentry/node'); - -class ErrorHistoryService { - constructor(err) { - console.log(err); - this.err = err; - this.message = err.message; - this.saveError(); - } - - saveError() { - try { - Sentry.captureException(this.err); - } catch (err) { - console.log('Não foi possível salvar o erro!'); - console.log(err); - } - } -} - -module.exports = ErrorHistoryService; diff --git a/src/services/HelpService.js b/src/services/HelpService.js index f505099d..bb73d2e5 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -6,7 +6,7 @@ const CategoryService = require('./CategoryService'); const { findConnections, sendMessage } = require('../../websocket'); const NotificationMixin = require('../utils/NotificationMixin'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); - +const saveError = require('../utils/ErrorHistory'); class HelpService { constructor() { @@ -104,7 +104,7 @@ class HelpService { const checkHelpStatusExistence = statusList.filter((item) => !Object.values(helpStatusEnum).includes(item)); if (checkHelpStatusExistence.length > 0) { - throw new Error('Um dos status informados é ínvalido.'); + throw new Error('Um dos status informados é ínvalido'); } const helpList = await this.HelpRepository.getHelpListByStatus(userId, statusList, helper); @@ -159,6 +159,7 @@ class HelpService { this.NotificationMixin.sendNotification(helper.deviceId, title, body); } catch (err) { console.log('Não foi possível enviar a notificação!'); + saveError(err); } return result; } @@ -203,6 +204,7 @@ class HelpService { this.NotificationService.createNotification(helperNotificationHistory); } catch (err) { console.log('Não foi possível enviar a notificação!'); + saveError(err); } help.status = 'finished'; @@ -257,6 +259,7 @@ class HelpService { this.NotificationService.createNotification(helperNotificationHistory); } catch (err) { console.log('Não foi possível enviar a notificação!'); + saveError(err); } help.status = 'finished'; @@ -313,6 +316,7 @@ class HelpService { this.NotificationService.createNotification(notificationHistory); } catch (err) { console.log('Não foi possível enviar a notificação!'); + saveError(err); } return result; diff --git a/src/utils/ErrorHistory.js b/src/utils/ErrorHistory.js new file mode 100644 index 00000000..e9f209ab --- /dev/null +++ b/src/utils/ErrorHistory.js @@ -0,0 +1,13 @@ +const Sentry = require('@sentry/node'); + +const saveError = async (incomingError) => { + console.log(incomingError); + try { + Sentry.captureException(incomingError); + } catch (err) { + console.log('Não foi possível salvar o erro. Sentry não está configurado.'); + console.log(err); + } +}; + +module.exports = saveError; diff --git a/src/utils/NotificationMixin.js b/src/utils/NotificationMixin.js index 3df40bd4..b65ddb34 100644 --- a/src/utils/NotificationMixin.js +++ b/src/utils/NotificationMixin.js @@ -17,11 +17,7 @@ class NotificationService { } messages.push(message); - try { - notify(messages); - } catch (err) { - console.log(err); - } + notify(messages); } } From 7a75ca99928a0cbd4335385d96d0bb60ddec2e6c Mon Sep 17 00:00:00 2001 From: darmsDD Date: Thu, 25 Jun 2020 20:47:00 -0300 Subject: [PATCH 17/28] Save error in notification and remove unused ifs in helpService. Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- src/controllers/NotificationController.js | 2 ++ src/services/HelpService.js | 16 ++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/controllers/NotificationController.js b/src/controllers/NotificationController.js index 638f8813..3ab67641 100644 --- a/src/controllers/NotificationController.js +++ b/src/controllers/NotificationController.js @@ -1,4 +1,5 @@ const NotificationService = require('../services/NotificationService'); +const saveError = require('../utils/ErrorHistory'); class NotificationController { constructor() { @@ -13,6 +14,7 @@ class NotificationController { res.status(200).json(result); next(); } catch (err) { + saveError(err); res.status(400).json({ error: err.message }); next(); } diff --git a/src/services/HelpService.js b/src/services/HelpService.js index bb73d2e5..b574fb6e 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -118,9 +118,7 @@ class HelpService { const { ownerId } = help; const helper = await this.UserService.getUser({ id: idHelper }); const owner = await this.UserService.getUser({ id: ownerId }); - if (!help) { - throw new Error('Ajuda não encontrada'); - } + if (help.helperId) { throw new Error('Ajuda já possui ajudante'); } @@ -161,6 +159,7 @@ class HelpService { console.log('Não foi possível enviar a notificação!'); saveError(err); } + return result; } throw new Error('Ajudante não encontrado'); @@ -171,9 +170,7 @@ class HelpService { const owner = await this.UserService.getUser({ id: help.ownerId }); const helper = await this.UserService.getUser({ id: help.helperId }); - if (!help) { - throw new Error('Ajuda não encontrada'); - } else if (help.helperId != data.helperId) { + if (help.helperId != data.helperId) { throw new Error('Usuário não é o ajudante dessa ajuda'); } else if (help.status === 'owner_finished') { const ownerTitle = 'Pedido de ajuda finalizado!'; @@ -226,9 +223,7 @@ class HelpService { const owner = await this.UserService.getUser({ id: help.ownerId }); const helper = await this.UserService.getUser({ id: help.helperId }); - if (!help) { - throw new Error('Ajuda não encontrada'); - } else if (help.ownerId != data.ownerId) { + if (help.ownerId != data.ownerId) { throw new Error('Usuário não é o dono da ajuda'); } else if (help.status === 'helper_finished') { const ownerTitle = 'Pedido de ajuda finalizado!'; @@ -278,9 +273,6 @@ class HelpService { async addPossibleHelpers(id, idHelper) { const help = await this.getHelpByid(id); const owner = await this.UserService.getUser({ id: help.ownerId }); - if (!help) { - throw new Error('Ajuda não encontrada'); - } if (idHelper == help.ownerId) { throw new Error('Você não pode ser ajudante de sua própria ajuda'); From 35f3be0d9cd9741d21ab4eeca886f8f88111142d Mon Sep 17 00:00:00 2001 From: darmsDD Date: Thu, 25 Jun 2020 20:49:05 -0300 Subject: [PATCH 18/28] Save error in User and remove unused ifs. Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- src/controllers/UserController.js | 22 +++++++---- src/services/UserService.js | 64 +++++++++++-------------------- 2 files changed, 37 insertions(+), 49 deletions(-) diff --git a/src/controllers/UserController.js b/src/controllers/UserController.js index a7d948f6..19c95816 100644 --- a/src/controllers/UserController.js +++ b/src/controllers/UserController.js @@ -1,5 +1,6 @@ const UserService = require('../services/UserService'); const { riskGroups } = require('../models/RiskGroup'); +const saveError = require('../utils/ErrorHistory'); class UserController { constructor() { @@ -25,7 +26,8 @@ class UserController { res.status(201).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + saveError(err); + res.status(400).json({ error: err.message }); next(); } } @@ -44,7 +46,8 @@ class UserController { res.status(200).json(result); return next(); } catch (err) { - res.status(400).json({ error: err }); + saveError(err); + res.status(400).json({ error: err.message }); return next(); } } @@ -64,7 +67,8 @@ class UserController { res.status(200).json(result); return next(); } catch (err) { - res.status(400).json({ error: err }); + saveError(err); + res.status(400).json({ error: err.message }); return next(); } } @@ -77,7 +81,8 @@ class UserController { res.status(200).json(result); return next(); } catch (err) { - res.status(400).json({ error: err }); + saveError(err); + res.status(400).json({ error: err.message }); return next(); } } @@ -93,7 +98,8 @@ class UserController { res.status(200).json(result); next(); } catch (err) { - res.status(404).json({ error: err }); + saveError(err); + res.status(404).json({ error: err.message }); next(); } } @@ -110,7 +116,8 @@ class UserController { res.status(200).json(result); next(); } catch (err) { - res.status(400).json({ error: err }); + saveError(err); + res.status(400).json({ error: err.message }); next(); } } @@ -123,7 +130,8 @@ class UserController { res.status(200).json(result); next(); } catch (err) { - res.status(404).json({ error: err }); + saveError(err); + res.status(404).json({ error: err.message }); next(); } } diff --git a/src/services/UserService.js b/src/services/UserService.js index 6f71838b..476da355 100644 --- a/src/services/UserService.js +++ b/src/services/UserService.js @@ -8,40 +8,36 @@ class UserService { async createUser(data) { if (data.password.length < 8) { - throw 'Senha inválida'; + throw new Error('Senha inválida'); } if (data.cpf.length >= 11) { data.cpf = data.cpf.replace(/[-.]/g, ''); } data.email = data.email.toLowerCase(); - try { - const createdUser = await this.userRepository.create(data); - - if (!data.hasUser) { - // Cria o usuário no firebase - await firebase - .auth() - .createUser({ - email: data.email, - password: data.password, - displayName: data.name, - }) - .catch(async (err) => { - await this.removeUser(data.email); - throw err; - }); - } - - return createdUser; - } catch (err) { - throw err; + const createdUser = await this.userRepository.create(data); + + if (!data.hasUser) { + // Cria o usuário no firebase + await firebase + .auth() + .createUser({ + email: data.email, + password: data.password, + displayName: data.name, + }) + .catch(async (err) => { + await this.removeUser(data.email); + throw err; + }); } + + return createdUser; } async getUser({ id = undefined, email = undefined }) { if (!id && !email) { - throw { id: 'Nenhum identificador encontrado' }; + throw new Error('Nenhum identificador encontrado'); } let user; @@ -51,7 +47,7 @@ class UserService { user = await this.userRepository.getUserByEmail(email); } if (!user) { - throw 'Usuário não encontrado'; + throw new Error('Usuário não encontrado'); } return user; @@ -67,10 +63,6 @@ class UserService { }) { const user = await this.getUser({ email }); - if (!user) { - throw 'Usuário não encontrado'; - } - user.photo = photo || user.photo; user.name = name || user.name; user.phone = phone || user.phone; @@ -87,10 +79,6 @@ class UserService { }) { const user = await this.getUser({ email }); - if (!user) { - throw 'Usuário não encontrado'; - } - const address = { cep: cep || user.address.cep, number: number || user.address.number, @@ -109,10 +97,6 @@ class UserService { async updateUserLocationById({ email, longitude, latitude }) { const user = await this.getUser({ email }); - if (!user) { - throw 'Usuário não encontrado'; - } - if (longitude || latitude) { user.location.coordinates[0] = longitude || user.location.coordinates[0]; user.location.coordinates[1] = latitude || user.location.coordinates[1]; @@ -134,12 +118,8 @@ class UserService { } async removeUser(email) { - try { - const user = await this.getUser({ email }); - await this.userRepository.removeUser({ id: user._id, email }); - } catch (err) { - console.log(err); - } + const user = await this.getUser({ email }); + await this.userRepository.removeUser({ id: user._id, email }); } async checkUserExistence(identificator) { From 892f794ebc39ee00e45f4cb53a879612d1c37905 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Thu, 25 Jun 2020 20:55:41 -0300 Subject: [PATCH 19/28] Throw error in correct format in BaseRepository. Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- src/repository/BaseRepository.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/repository/BaseRepository.js b/src/repository/BaseRepository.js index 0063d54a..23f15071 100644 --- a/src/repository/BaseRepository.js +++ b/src/repository/BaseRepository.js @@ -48,7 +48,7 @@ class BaseRepository { try { finalIdFormat = mongoose.Types.ObjectId(id); } catch (err) { - throw 'Tamanho ou formato de id inválido'; + throw new Error('Tamanho ou formato de id inválido'); } } From 55d3f151b994e122c54c84064a64c550f84ec2e6 Mon Sep 17 00:00:00 2001 From: Danillo Souza Date: Wed, 1 Jul 2020 16:47:45 -0300 Subject: [PATCH 20/28] Added emailVerified field to user --- src/services/UserService.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/UserService.js b/src/services/UserService.js index 6f71838b..60d2c7f5 100644 --- a/src/services/UserService.js +++ b/src/services/UserService.js @@ -19,6 +19,7 @@ class UserService { const createdUser = await this.userRepository.create(data); if (!data.hasUser) { + console.log('Usuario Criado'); // Cria o usuário no firebase await firebase .auth() @@ -26,6 +27,7 @@ class UserService { email: data.email, password: data.password, displayName: data.name, + emailVerified: false }) .catch(async (err) => { await this.removeUser(data.email); @@ -53,7 +55,6 @@ class UserService { if (!user) { throw 'Usuário não encontrado'; } - return user; } From 8e23d85a0e1a7f1b2cacc89ab27907079ec6f3db Mon Sep 17 00:00:00 2001 From: darmsDD Date: Wed, 1 Jul 2020 18:50:49 -0300 Subject: [PATCH 21/28] Save error in case user is not authenticated or not authorized. Co-authored-by: Ivan Dobbin Co-authored-by: Welison Almeida --- src/validation/middlewares/authFirebase.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/validation/middlewares/authFirebase.js b/src/validation/middlewares/authFirebase.js index 5c8bb63d..85fd9988 100644 --- a/src/validation/middlewares/authFirebase.js +++ b/src/validation/middlewares/authFirebase.js @@ -1,4 +1,5 @@ const admin = require('../../config/authFirebase'); +const saveError = require('../../utils/ErrorHistory'); const isAuthenticated = async (req, res, next) => { if (req.headers.authorization @@ -11,10 +12,13 @@ const isAuthenticated = async (req, res, next) => { req.decodedToken = idToken; return next(); } catch (err) { + saveError(err); return res.status(401).json({ error: 'Usuário não autorizado' }); } } - return res.status(403).json({ error: 'Usuário não está autenticado' }); + const err = new Error('Usuário não está autenticado'); + saveError(err); + return res.status(403).json({ error: err.message }); }; module.exports = isAuthenticated; From 49141454bbf774780d8af045b42a065e7815cd4a Mon Sep 17 00:00:00 2001 From: Welison Almeida Date: Wed, 1 Jul 2020 20:01:50 -0300 Subject: [PATCH 22/28] Update README.md. --- README.md | 81 ++++++++++++++++++---- src/public/assets/images/MiaAjudaLogo.png | Bin 0 -> 17709 bytes 2 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 src/public/assets/images/MiaAjudaLogo.png diff --git a/README.md b/README.md index 05109c3a..24e54438 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,74 @@ -# Mia Ajuda - Backend +

+ Logo Mia Ajuda +

- +

+ + + + +

-## Rode com Docker +## Rode o Backend com Docker -Para executar localmente a aplicação, proceda com os seguintes passos: +### Dependências -1. Instale o Docker [neste link](https://docs.docker.com/install/linux/docker-ce/ubuntu/). -2. Instale o Docker Compose [neste link](https://docs.docker.com/compose/install/). -3. Pegue o arquivo firebaseConfig.js e firebaseConfig-dev.js do drive na pasta firebase e coloque-o dentro da pasta config do projeto. -4. Crie um arquivo .env e dentro dele crie 2 váriaveis de ambiente LATITUDE_ENV= e LONGITUDE_ENV= -5. Coloque a latitude e longitude de sua casa nas variáveis de ambiente. -6. Na pasta principal do projeto, construa e inicialize a aplicação com o comando: `sudo docker-compose -f docker-compose.yml up --build`. -7. O backend estará disponível em: `http://localhost:8000/`. +Inicialmente, instale localmente as seguintes dependências: -* Observação: por padrão, o docker-compose iniciará a API com `yarn start`. +1. Instale o [Docker](https://docs.docker.com/install/linux/docker-ce/ubuntu/); +2. Instale o [Docker Compose](https://docs.docker.com/compose/install/). + +### Arquivos de Configuração + +1. A aplicação utiliza-se de autenticação por meio do [firebase](https://firebase.google.com/), logo, insira na pasta `src/config` o arquivo `firebaseConfig-dev.js`. O arquivo de configuração obtido do firebase deve apresentar a seguinte fisionomia: + +```js +const config = { + type: '', + project_id: '', + private_key_id: '', + private_key: '', + client_email: '', + client_id: '', + auth_uri: '', + token_uri: '', + auth_provider_x509_cert_url: '', + client_x509_cert_url: '', +}; + +const databaseURL = ''; + +module.exports = { + config, + databaseURL, +}; +``` + +2. Crie um arquivo `.env` na raiz do projeto e preencha as seguintes variáveis de ambiente: + +```env +LATITUDE_ENV= +LONGITUDE_ENV= +SENTRY_DSN= +NODE_ENV=development +DATABASE_URL=mongodb://mongo/miaAjudaDB +``` + +* 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. + +### Inicialização do Projeto + +1. Na pasta principal do projeto, construa e inicialize a aplicação com o comando: + +```bash +sudo docker-compose -f docker-compose.yml up --build +``` + +2. O backend estará disponível em: `http://localhost:8000/`. + +### Configuração do ESLint + +1. Instale globalmente o pacote do eslint: `npm i -g eslint`; +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. diff --git a/src/public/assets/images/MiaAjudaLogo.png b/src/public/assets/images/MiaAjudaLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..e833d19a2ff366511c0372cab038b629f4cc24ee GIT binary patch literal 17709 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 Date: Wed, 1 Jul 2020 20:02:12 -0300 Subject: [PATCH 23/28] Update environment variables example. --- .env-example | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.env-example b/.env-example index 949d6b64..a7b7be94 100644 --- a/.env-example +++ b/.env-example @@ -1,2 +1,5 @@ -DATABASE_URL= -NODE_ENV=[development|production] \ No newline at end of file +LATITUDE_ENV= +LONGITUDE_ENV= +SENTRY_DSN= +NODE_ENV=development +DATABASE_URL=mongodb://mongo/miaAjudaDB \ No newline at end of file From 0541542674dfb3d986afa1a355315e7d289c4da2 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Thu, 2 Jul 2020 18:16:49 -0300 Subject: [PATCH 24/28] Sort by distance and remove filter of distance in helps. Co-authored-by: Ivan Dobbin Co-authored-by: Pedro Feo --- src/repository/HelpRepository.js | 74 +++++--------------------------- 1 file changed, 10 insertions(+), 64 deletions(-) diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index d1ccc921..a11ad7bf 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -2,7 +2,7 @@ const { ObjectID } = require('mongodb'); const BaseRepository = require('./BaseRepository'); const HelpSchema = require('../models/Help'); const UserSchema = require('../models/User'); -const { getDistance } = require('../utils/geolocation/calculateDistance'); +const { getDistance, calculateDistance } = require('../utils/geolocation/calculateDistance'); class HelpRepository extends BaseRepository { constructor() { @@ -158,18 +158,8 @@ class HelpRepository extends BaseRepository { async listNear(coords, except, id, categoryArray) { const query = {}; - const location = { - $near: { - $geometry: { - type: 'Point', - coordinates: coords, - }, - $maxDistance: 2000, - }, - }; const ownerId = except ? { $ne: id } : null; - query.location = location; query._id = ownerId; const users = await UserSchema.find(query); @@ -207,57 +197,6 @@ class HelpRepository extends BaseRepository { preserveNullAndEmptyArrays: false, }, }, - { - $addFields: { - ageRisk: { - $cond: [ - { - $gt: [ - { - $subtract: [ - { - $year: '$$NOW', - }, - { - $year: '$user.birthday', - }, - ], - }, - 60, - ], - }, - 1, - 0, - ], - }, - cardio: { - $cond: [ - { - $in: ['$user.riskGroup', [['doenCardio']]], - }, - 1, - 0, - ], - }, - risco: { - $size: '$user.riskGroup', - }, - }, - }, - { - $sort: { - ageRisk: -1, - cardio: -1, - risco: -1, - }, - }, - { - $project: { - ageRisk: 0, - cardio: 0, - risco: 0, - }, - }, { $lookup: { from: 'category', @@ -287,10 +226,17 @@ class HelpRepository extends BaseRepository { longitude: help.user.location.coordinates[0], }; help.distance = getDistance(coordinates, helpCoords); - + help.distanceValue = calculateDistance(coordinates, helpCoords); return help; }); - + helpsWithDistance.sort((a, b) => { + if (a.distanceValue < b.distanceValue) { + return -1; + } if (a.distanceValue > b.distanceValue) { + return 1; + } + return 0; + }); return helpsWithDistance; } From 1ac085ff0c60c735c0305d5a4009db58b30f2dda Mon Sep 17 00:00:00 2001 From: darmsDD Date: Fri, 3 Jul 2020 17:19:16 -0300 Subject: [PATCH 25/28] Remove filter by distance in socket. Co-authored-by: Ivan Dobbin Co-authored-by: Pedro Feo --- src/services/HelpService.js | 22 +++------------------- websocket.js | 37 +++---------------------------------- 2 files changed, 6 insertions(+), 53 deletions(-) diff --git a/src/services/HelpService.js b/src/services/HelpService.js index b574fb6e..c70c3f1c 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -27,15 +27,9 @@ class HelpService { const createdHelp = await this.HelpRepository.create(data); - const user = await this.UserService.getUser({ id: createdHelp.ownerId }); - const userCoords = { - longitude: user.location.coordinates[0], - latitude: user.location.coordinates[1], - }; const sendSocketMessageTo = findConnections( - userCoords, createdHelp.categoryId, - JSON.parse(JSON.stringify(user._id)), + JSON.parse(JSON.stringify(createdHelp.ownerId)), ); sendMessage(sendSocketMessageTo, 'new-help', createdHelp); @@ -88,13 +82,8 @@ class HelpService { await this.HelpRepository.update(help); - const user = await this.UserService.getUser({ id: help.ownerId }); - const userCoords = { - longitude: user.location.coordinates[0], - latitude: user.location.coordinates[1], - }; help = JSON.parse(JSON.stringify(help)); - const sendSocketMessageTo = findConnections(userCoords, help.categoryId, JSON.parse(JSON.stringify(user._id))); + const sendSocketMessageTo = findConnections(help.categoryId, JSON.parse(JSON.stringify(help.ownerId))); sendMessage(sendSocketMessageTo, 'delete-help', id); return { message: `Help ${id} deleted!` }; @@ -123,14 +112,9 @@ class HelpService { throw new Error('Ajuda já possui ajudante'); } - const ownerCoords = { - longitude: owner.location.coordinates[0], - latitude: owner.location.coordinates[1], - }; const sendSocketMessageTo = findConnections( - ownerCoords, help.categoryId, - JSON.parse(JSON.stringify(owner._id)), + JSON.parse(JSON.stringify(ownerId)), ); sendMessage(sendSocketMessageTo, 'delete-help', help._id); diff --git a/websocket.js b/websocket.js index cbabb6bb..bf9043c6 100644 --- a/websocket.js +++ b/websocket.js @@ -14,17 +14,9 @@ exports.setupWebsocket = (server) => { id: socket.id, userId, currentRegion, - locations: [currentRegion], categories: [], }); - socket.on('change-locations', (locations) => { - const index = connections.map((connection) => connection.id).indexOf(socket.id); - if (index >= 0) { - connections[index].locations = locations; - } - }); - socket.on('change-categories', (categories) => { const index = connections.map((connection) => connection.id).indexOf(socket.id); if (index >= 0) { @@ -41,20 +33,12 @@ exports.setupWebsocket = (server) => { }); }; -function canParse(locs) { - try { - JSON.parse(locs); - return true; - } catch (err) { - return false; - } -} -exports.findConnections = (coordinates, category, userId) => { +exports.findConnections = (category, userId) => { const filtered = connections.filter((connection) => { if (userId === connection.userId) { return false; } - if (connection.categories && connection.categories.length) { + if (connection.categories.length) { const { categories } = connection; let categoryExist = false; for (let i = 0; i < categories.length; i += 1) { @@ -67,22 +51,7 @@ exports.findConnections = (coordinates, category, userId) => { return false; } } - let should = false; - let locs = connection.locations; - if (canParse(locs)) { - locs = [JSON.parse(locs)]; - } - locs.every((location) => { - let distance = calculateDistance(coordinates, location); - if (distance < 2) { - distance = getDistance(JSON.parse(connection.currentRegion), coordinates); - connection.distance = distance; - should = true; - return false; - } - return true; - }); - return should; + return true; }); return filtered; }; From bf5bc771a7d31ab8931bcd6e5a41beb6f3e33c72 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Mon, 6 Jul 2020 17:51:21 -0300 Subject: [PATCH 26/28] Insert distanceValue in socket with createHelps. Co-authored-by: Ivan Dobbin Co-authored-by: Pedro Feo --- websocket.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket.js b/websocket.js index bf9043c6..0d4319bb 100644 --- a/websocket.js +++ b/websocket.js @@ -1,5 +1,5 @@ const socketio = require('socket.io'); -const { calculateDistance, getDistance } = require('./src/utils/geolocation/calculateDistance'); +const { calculateDistance } = require('./src/utils/geolocation/calculateDistance'); let io; const connections = []; @@ -58,7 +58,15 @@ exports.findConnections = (category, userId) => { exports.sendMessage = (to, message, data) => { to.forEach((connection) => { - data.distance = connection.distance; + if (typeof (data) === 'object') { + const userLocation = JSON.parse(connection.currentRegion); + const helpLocation = { + latitude: data.user.location.coordinates[1], + longitude: data.user.location.coordinates[0], + }; + data.distanceValue = calculateDistance(helpLocation, userLocation); + } + io.to(connection.id).emit(message, data); }); }; From 02b35499bed514400e7c4e166ec507993ad054db Mon Sep 17 00:00:00 2001 From: darmsDD Date: Mon, 13 Jul 2020 14:11:49 -0300 Subject: [PATCH 27/28] Calculate distance only when a help is created --- websocket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocket.js b/websocket.js index 0d4319bb..a7e14129 100644 --- a/websocket.js +++ b/websocket.js @@ -58,7 +58,7 @@ exports.findConnections = (category, userId) => { exports.sendMessage = (to, message, data) => { to.forEach((connection) => { - if (typeof (data) === 'object') { + if (typeof (data) === 'object' && message == 'new-help') { const userLocation = JSON.parse(connection.currentRegion); const helpLocation = { latitude: data.user.location.coordinates[1], From ba47cbcca3d561f5d054a0daaec53dbb9ed02182 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jul 2020 04:34:24 +0000 Subject: [PATCH 28/28] Bump lodash from 4.17.15 to 4.17.19 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 1360e678..a3fc6866 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "express": "^4.17.1", "faker": "^4.1.0", "firebase-admin": "^8.10.0", - "lodash": "^4.17.15", + "lodash": "^4.17.19", "mongodb": "^3.5.9", "mongoose": "^5.9.6", "node-schedule": "^1.3.2", diff --git a/yarn.lock b/yarn.lock index 0f4f2401..75ab4c1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2416,10 +2416,10 @@ lodash.once@^4.0.0: resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" integrity sha1-DdOXEhPHxW34gJd9UEyI+0cal6w= -lodash@^4.17.14, lodash@^4.17.15: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19: + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== long-timeout@0.1.1: version "0.1.1"