Node noob question here, I'm sure.
I have the code below in a simple express JS application
var randomPin = require('./api/randomPin');
var currentPin = "pin";
app.post('/match', function(req, res) {
if (req.body.pin && req.body.pin == currentPin) {
currentPin = randomPin.generate();
res.send({hurrah:true});
}
res.send({hurrah:false});
});
I'm still not viewing the Node request workflow ...
Is a race condition possible when two message requests are processed simultaneously /match, so that both records try to call randomPin.generate()?
If this is the best way to avoid this?
source
share