return random names instead of John Doe in beneficiary validation
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
const { logger } = require('../util/logger');
|
const { logger } = require('../util/logger');
|
||||||
const beneficiaryService = require('../services/beneficiary.service');
|
const beneficiaryService = require('../services/beneficiary.service');
|
||||||
const db = require('../config/db');
|
const db = require('../config/db');
|
||||||
|
const randomName = require('../util/name.generator');
|
||||||
|
|
||||||
async function validateWithinBank(req, res) {
|
async function validateWithinBank(req, res) {
|
||||||
const { accountNumber } = req.query;
|
const { accountNumber } = req.query;
|
||||||
@@ -40,7 +41,8 @@ async function validateOutsideBank(req, res) {
|
|||||||
return res.status(401).json({ error: 'invalid account number' });
|
return res.status(401).json({ error: 'invalid account number' });
|
||||||
//**IN PRODUCTION** poll the redis server continuously giving the refNo since the response from NPCI will be stored there
|
//**IN PRODUCTION** poll the redis server continuously giving the refNo since the response from NPCI will be stored there
|
||||||
await delay(3000);
|
await delay(3000);
|
||||||
return res.json({ name: 'John Doe' });
|
const name = randomName();
|
||||||
|
return res.json({ name });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err, 'beneficiary validation within bank failed');
|
logger.error(err, 'beneficiary validation within bank failed');
|
||||||
res.status(500).json({ error: 'invalid account number' });
|
res.status(500).json({ error: 'invalid account number' });
|
||||||
|
36
src/util/name.generator.js
Normal file
36
src/util/name.generator.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
const indianFirstNames = [
|
||||||
|
'Aarav',
|
||||||
|
'Vivaan',
|
||||||
|
'Aditya',
|
||||||
|
'Vihaan',
|
||||||
|
'Krishna',
|
||||||
|
'Ishaan',
|
||||||
|
'Rohan',
|
||||||
|
'Ananya',
|
||||||
|
'Diya',
|
||||||
|
'Aisha',
|
||||||
|
'Priya',
|
||||||
|
'Sneha',
|
||||||
|
];
|
||||||
|
const indianLastNames = [
|
||||||
|
'Sharma',
|
||||||
|
'Verma',
|
||||||
|
'Iyer',
|
||||||
|
'Reddy',
|
||||||
|
'Patel',
|
||||||
|
'Mehta',
|
||||||
|
'Choudhary',
|
||||||
|
'Kumar',
|
||||||
|
'Das',
|
||||||
|
'Rao',
|
||||||
|
];
|
||||||
|
|
||||||
|
function getRandomIndianName() {
|
||||||
|
const firstName =
|
||||||
|
indianFirstNames[Math.floor(Math.random() * indianFirstNames.length)];
|
||||||
|
const lastName =
|
||||||
|
indianLastNames[Math.floor(Math.random() * indianLastNames.length)];
|
||||||
|
return `${firstName} ${lastName}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getRandomIndianName;
|
Reference in New Issue
Block a user