Skip to content

Commit

Permalink
Merge pull request #181 from ong-bitcoin-argentina/MM-424/control-sem…
Browse files Browse the repository at this point in the history
…illas-endpoint

MM-424 / Control de rutas de semillas
  • Loading branch information
fedelmar committed Aug 13, 2021
2 parents f90e340 + 3f8ad10 commit 0751ee9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions constants/Constants.js
Expand Up @@ -77,6 +77,7 @@ const { APP_INSIGTHS_IKEY } = process.env;
if (APP_INSIGTHS_IKEY == null || APP_INSIGTHS_IKEY == '') throw new Error('No esta definida la varibale APP_INSIGTHS_IKEY');

// Semillas
const ENABLE_SEMILLAS = process.env.ENABLE_SEMILLAS === 'true';
const { SEMILLAS_USERNAME, SEMILLAS_PASSWORD, SEMILLAS_URL } = process.env;
if (SEMILLAS_USERNAME == null || SEMILLAS_USERNAME == '') throw new Error('No esta definida la varibale SEMILLAS_USERNAME');
if (SEMILLAS_PASSWORD == null || SEMILLAS_PASSWORD == '') throw new Error('No esta definida la varibale SEMILLAS_PASSWORD');
Expand Down Expand Up @@ -238,6 +239,7 @@ module.exports = {
NO_EMAILS,
NO_SMS,

ENABLE_SEMILLAS,
SEMILLAS_LOGIN: {
username: SEMILLAS_USERNAME,
password: SEMILLAS_PASSWORD,
Expand Down
12 changes: 12 additions & 0 deletions middlewares/semillas.js
@@ -0,0 +1,12 @@
const { ENABLE_SEMILLAS } = require('../constants/Constants');
const ResponseHandler = require('../utils/ResponseHandler');

const semillasMiddelware = (req, res, next) => {
if (!ENABLE_SEMILLAS) {
ResponseHandler.sendErrWithStatus(res, 'Rutas de Semillas deshabilitadas', 403);
} else next();
};

module.exports = {
semillasMiddelware,
};
4 changes: 3 additions & 1 deletion routes/SemillasRoutes.js
@@ -1,9 +1,11 @@
/* eslint-disable max-len */

const router = require('express').Router();
const Constants = require('../constants/Constants');
const { checkValidationResult, validateBody } = require('../utils/Validator');
const semillas = require('../controllers/semillas');
const { semillasMiddelware } = require('../middlewares/semillas');

router.use('/semillas/', semillasMiddelware);

const {
IS_STRING, IS_EMAIL, IS_DNI, IS_MOBILE_PHONE, IS_NUMBER,
Expand Down

0 comments on commit 0751ee9

Please sign in to comment.