menu

SFRA / Server-side JS / Class: Server

Server

Server is a routing solution

Constructor

new Server()

Source:

Methods

append(name, arguments) → {void}

Modify a given route by appending additional middleware to it

Parameters:
Name Type Description
name string

Name of the route to modify

arguments Array.<function()>

List of functions to be appended

Source:
Returns:
Type
void

extend(server) → {void}

Extend existing server object with a list of registered routes

Parameters:
Name Type Description
server Object

Object that corresponds to the output of "exports" function

Source:
Returns:
Type
void

get(name, arguments) → {void}

Shortcut to "use" method that adds a check for get request

Parameters:
Name Type Description
name string

Name of the route

arguments Array.<function()>

List of functions to be executed

Source:
Returns:
Type
void

getRoute(name) → {Object}

Returns a given route from the server

Parameters:
Name Type Description
name string

Name of the route

Source:
Returns:

Route that matches the name that was passed in

Type
Object

post(name, arguments) → {void}

Shortcut to "use" method that adds a check for post request

Parameters:
Name Type Description
name string

Name of the route

arguments Array.<function()>

List of functions to be executed

Source:
Returns:
Type
void

prepend(name, arguments) → {void}

Modify a given route by prepending additional middleware to it

Parameters:
Name Type Description
name string

Name of the route to modify

arguments Array.<function()>

List of functions to be appended

Source:
Returns:
Type
void

replace(name, arguments) → {void}

Replace a given route with the new one

Parameters:
Name Type Description
name string

Name of the route to replace

arguments Array.<function()>

List of functions for the route

Source:
Returns:
Type
void

use(name, arguments) → {void}

Creates a new route with a name and a list of middleware

Parameters:
Name Type Description
name string

Name of the route

arguments Array.<function()>

List of functions to be executed

Source:
Returns:
Type
void

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.