i made this to save a some info on a file and to read line by line using readline node module
there is two res.send() one is with return . it only return within current function its sitting on . How do i completely exit from then functions?
this just for a test . I know I should use Databases
router.post('/login', (req, res) => {
    console.log(req.body);
    var lineReader = require('readline').createInterface({
        input: require('fs').createReadStream('./users.txt')
    });
    lineReader.on('line', function (line) {
        const lineJson = JSON.parse(line);
        if (lineJson["username"] == req.body.username) {
            if (lineJson["password"] == req.body.password) {
                return res.send({ msg: "matched" });
            }
        }
    })
res.send({msg:"not matched"});
})
simplified
function(){
    function(){
        return...
    }
}
 
     
    