Module: nationscript/request/ratelimit

Provides built-in rate-limiting functionality.

Methods

(async, inner) enforce()

Enforces compliance with the API's general rate-limit.

Depending on how many requests have been sent to the NS API in the current time window already, further execution is paused for an appropriate amount of time, until a new request can be made again safely.

(async, inner) enforceTG(isRecruit)

Enforces compliance with the API's telegram rate-limit.

Depending on when the last telegram request was sent, further execution is paused for an appropriate amount of time, until a new telegram request can be made again safely.

Parameters:
Name Type Description
isRecruit boolean

true to enforce the rate-limit as required for recruitment telegrams, otherwise false

(inner) update(data)

Updates the rate-limiters records with data supplied by the API.

Parameters:
Name Type Description
data http.IncomingHttpHeaders

Headers returned