Endpoints

Endpoints

Source:
To Do:
  • Add a rate limiter to our HTTP endpoint module

Reaction Endpoints - This becomes Reaction.Endpoints and can be used in any server side code Adapted from https://github.com/stubailo/meteor-rest/tree/master/packages/json-routes

Methods

(static) add(method, path, handler) → {undefined}

Source:
Example
Reaction.Endpoints.add("post", "/webhooks/shopify/orders-create", function (req, res){})
Parameters:
Name Type Description
method String

HTTP method

path String

HTTP path - Make sure path starts with a slash

handler function

Callback handler

Returns:
Type
undefined

(static) sendResponse(res, optionsopt) → {void}

Sets the response headers, status code, and body, and ends it. The JSON response will be pretty printed if NODE_ENV is development.

Source:
Example
Reaction.Endpoints.sendResponse(res)
Parameters:
Name Type Attributes Description
res Object

Response object

options Object <optional>

Options object

Properties
Name Type Attributes Description
code Number <optional>

HTTP status code. Default is 200.

headers Object <optional>

Dictionary of headers.

data Object | Array | null | undefined <optional>

The object to stringify as the response. If null, the response will be "null". If undefined, there will be no response body.

Returns:
Type
void

(static) setResponseHeaders(headers) → {undefined}

Source:
Parameters:
Name Type Description
headers Object

HTTP headers

Returns:
Type
undefined