SFRA Server-side Javascript - Class: Route menu

SFRA / Server-side JS / Class: Route

Route

new Route(name, chain, req, res)

Parameters:
Name Type Description
name string

Name of the route, corresponds to the second part of the URL

chain Array.<function()>

List of functions to be executed

req Object

Request object

res Object

Response object

Source:

Methods

append(step) → {void}

Append a middleware step into current chain

Parameters:
Name Type Description
step function

New middleware step

Source:
Returns:
Type
void

done(req, res) → {void}

Last step in the chain, this will render a template or output a json string

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

Source:
Returns:
Type
void

getRoute() → {function}

Create a single function that chains all of the calls together, one after another

Source:
Returns:

Function to be executed when URL is hit

Type
function