FAQ
But if a user hits Refresh (F5) twice instantly for example, I only want
the code to run once. But refreshing twice means two response objects. And
I can only send a valid response to the 2nd created response object. (The
first one wont work, according to tests) so I can't ignore requests either

Den torsdagen den 13:e november 2014 kl. 20:19:46 UTC+1 skrev Aria Stewart:

On Nov 13, 2014, at 12:59 PM, Alex Spencer <alex...@gmail.com
<javascript:>> wrote:

Hi.

Imagine a simple route like this:

app.get('/test',
apiCall1(),
apiCall2(),
apiCall3(),
apiCall4(),
apiCall5(),
renderPage()

How would you prevent this code from being executed by the same client
while said client is spamming GET requests (either by refresh page or
clicking buttons, etc.) to the same route ?


I'd add another middleware at the head of the chain that keeps track of
the accesses by a given client (session ID? IP address? Identifying a
client can be its own problem, depending!), and errors (with next(an error
here)) if the user is over-requesting. Defining that is up to you.

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/92e9039c-87e3-4c43-b15a-aa1b9a0cb4e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 8 | next ›
Discussion Overview
groupnodejs @
categoriesnodejs
postedNov 13, '14 at 7:10p
activeDec 1, '14 at 3:11p
posts8
users5
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase