Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MM-424 / Control de rutas de semillas #181

Merged
merged 3 commits into from Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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