Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
limit execution of a function for specified user at one per minute

I have a route like this to execute a function:

router.post('/send-verification-again', sendVerificationAgain);

At the function above we have the email or phone number of the account in which we want to verify.

This will execute a function to send an email or sms to the user with his/her verification code ok?

Apparently we don't want the user to be able to send more than one request per minute to this route, right?

How can I limit execution of a function for specified user at one per minute?

function sendVerificationAgain(email) {
  // for each specific email here the function can be executed one time per minute
}

This is very common functionality, is there any convention to do this?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can simply store the email for a minute and check if it's stored:

const recentlySent = new Set();

function sendVerificationAgain(email) {
    if (recentlySent.has(email)) return;
    recentlySent.add(email);
    setTimeout(() => recentlySent.delete(email), 60e3);
    // ...
}

You might also want to first normalize the email, e.g. lowercase it.

For more information, look up "debounce" in the programming sense

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!