Class: default
controllers/rest/RESTController.default
Table of contents
Constructors
Properties
Methods
- addCookie
- addRequestHandler
- addResponseHandler
- createCookie
- fetchXCSRFToken
- getCookies
- getProxy
- getUserAgent
- getXCSRFToken
- getXCSRFTokenRefreshInterval
- getXCSRFTokenRefreshMaxRetries
- request
- setOptions
- setProxy
- setUserAgent
- setXCSRFToken
- setXCSRFTokenRefreshInterval
- setXCSRFTokenRefreshMaxRetries
Constructors
constructor
+ new default(client
: default, options?
: RESTControllerOptions): default
Parameters:
Name | Type |
---|---|
client |
default |
options? |
RESTControllerOptions |
Returns: default
Defined in: controllers/rest/RESTController.ts:27
Properties
client
• client: default
Defined in: controllers/rest/RESTController.ts:22
cookieJar
• cookieJar: CookieJar
Defined in: controllers/rest/RESTController.ts:25
options
• options: RESTControllerOptions
Defined in: controllers/rest/RESTController.ts:23
requestHandlers
• requestHandlers: RESTRequestHandler[]
Defined in: controllers/rest/RESTController.ts:27
requester
• requester: RESTRequester
Defined in: controllers/rest/RESTController.ts:24
responseHandlers
• responseHandlers: RESTResponseHandler[]
Defined in: controllers/rest/RESTController.ts:26
Methods
addCookie
▸ addCookie(cookie
: Cookie, domain?
: string, setCookieOptions?
: any): Cookie
Adds a cookie to the cookie jar
Parameters:
Name | Type | Description |
---|---|---|
cookie |
Cookie | The cookie to add |
domain? |
string | The domain to add it for |
setCookieOptions? |
any | Options for setting the cookie |
Returns: Cookie
Defined in: controllers/rest/RESTController.ts:126
addRequestHandler
▸ addRequestHandler(handler
: RESTRequestHandler): void
Adds a request handler
Parameters:
Name | Type | Description |
---|---|---|
handler |
RESTRequestHandler | The request handler |
Returns: void
Defined in: controllers/rest/RESTController.ts:151
addResponseHandler
▸ addResponseHandler(handler
: RESTResponseHandler): void
Adds a response handler
Parameters:
Name | Type | Description |
---|---|---|
handler |
RESTResponseHandler | The response handler |
Returns: void
Defined in: controllers/rest/RESTController.ts:143
createCookie
▸ createCookie(cookieOptions
: RESTCreateCookieOptions): Cookie
Creates a new cookie and returns it, no side effects
Parameters:
Name | Type | Description |
---|---|---|
cookieOptions |
RESTCreateCookieOptions | The options to use |
Returns: Cookie
Defined in: controllers/rest/RESTController.ts:112
fetchXCSRFToken
▸ fetchXCSRFToken(): Promise<string>
Fetches a new XCSRF token
Returns: Promise<string>
Defined in: controllers/rest/RESTController.ts:74
getCookies
▸ getCookies(domain
: string): Cookie[]
Gets the cookies for a given domain stored in the jar
Parameters:
Name | Type | Description |
---|---|---|
domain |
string | The domain to retrieve the cookies for |
Returns: Cookie[]
Defined in: controllers/rest/RESTController.ts:135
getProxy
▸ getProxy(): undefined | string
Gets the proxy used
Returns: undefined | string
Defined in: controllers/rest/RESTController.ts:167
getUserAgent
▸ getUserAgent(): undefined | string
Gets the user agent
Returns: undefined | string
Defined in: controllers/rest/RESTController.ts:183
getXCSRFToken
▸ getXCSRFToken(): Promise<undefined | string>
Gets the existing XCSRF token if it's not older than set refresh interval, otherwise, fetch a new one
Returns: Promise<undefined | string>
Defined in: controllers/rest/RESTController.ts:95
getXCSRFTokenRefreshInterval
▸ getXCSRFTokenRefreshInterval(): undefined | number
Gets the XCSRF token refresh interval
Returns: undefined | number
Defined in: controllers/rest/RESTController.ts:199
getXCSRFTokenRefreshMaxRetries
▸ getXCSRFTokenRefreshMaxRetries(): undefined | number
Gets the amount of retries to be made to refresh XCSRF tokens on Token Validation errors
Returns: undefined | number
Defined in: controllers/rest/RESTController.ts:217
request
▸ request(options
: RESTRequestOptions): Promise<RESTResponseDataType>
Sends a request
Parameters:
Name | Type | Description |
---|---|---|
options |
RESTRequestOptions | The options |
Returns: Promise<RESTResponseDataType>
Defined in: controllers/rest/RESTController.ts:64
setOptions
▸ setOptions(options?
: RESTControllerOptions): RESTControllerOptions
Sets the options for the RESTController
Parameters:
Name | Type | Description |
---|---|---|
options? |
RESTControllerOptions | The options to use |
Returns: RESTControllerOptions
Defined in: controllers/rest/RESTController.ts:226
setProxy
▸ setProxy(proxyURL
: string): void
Sets the proxy for the requests
Parameters:
Name | Type | Description |
---|---|---|
proxyURL |
string | The proxy URL |
Returns: void
Defined in: controllers/rest/RESTController.ts:159
setUserAgent
▸ setUserAgent(userAgent
: string): void
Sets the user agents for future requests
Parameters:
Name | Type | Description |
---|---|---|
userAgent |
string | The user agent to use |
Returns: void
Defined in: controllers/rest/RESTController.ts:175
setXCSRFToken
▸ setXCSRFToken(token
: string): void
Sets the XCSRF token
Parameters:
Name | Type | Description |
---|---|---|
token |
string | The xcsrf token to use in future requets |
Returns: void
Defined in: controllers/rest/RESTController.ts:86
setXCSRFTokenRefreshInterval
▸ setXCSRFTokenRefreshInterval(xcsrfRefreshInterval
: number): void
Sets the XCSRF token refresh interval
Parameters:
Name | Type | Description |
---|---|---|
xcsrfRefreshInterval |
number | The time in ms to use |
Returns: void
Defined in: controllers/rest/RESTController.ts:191
setXCSRFTokenRefreshMaxRetries
▸ setXCSRFTokenRefreshMaxRetries(xcsrfRefreshMaxRetries
: number): void
Sets the amount of retries to be made to refresh XCSRF tokens on Token Validation errors
Parameters:
Name | Type | Description |
---|---|---|
xcsrfRefreshMaxRetries |
number | Number of retries |
Returns: void
Defined in: controllers/rest/RESTController.ts:208