Constructor
new ServerUtils()
- Source:
Methods
(static) addErrorHandler(next)
- Description:
- Adds extra properties to the request object to allow for easy translations
- Source:
Parameters:
Name |
Type |
Description |
next |
function
|
|
(static) addExistenceProps(req, res, next)
- Description:
- Adds extra properties to the request object to allow for easy existence checking of common request objects
- Source:
Example
"IMPORTANT NOTE: body data is completely ignored for GET requests, any code
requiring it should switch to use POST."
let req = { 'params': { 'foo':'bar' }, 'query': {}, 'body': {} };
req.hasParams // true
req.hasQuery // false
req.hasBody // false
Parameters:
Name |
Type |
Description |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
next |
function
|
|
(static) apiNotFoundHandler(req, res, next)
- Description:
- Middleware for handling 404 errors on the API router
- Source:
Parameters:
Name |
Type |
Description |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
next |
function
|
|
(static) cacheRouteConfig(routeConfig) → {function}
- Description:
- Caches the route config on the incoming request
- Source:
Parameters:
Name |
Type |
Description |
routeConfig |
Route
|
|
Returns:
-
Type
-
function
(async, static) debugRequestTime(req, res, next)
- Description:
- Adds logs for debugging each request time
- Source:
Parameters:
Name |
Type |
Description |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
next |
function
|
|
(static) generateRouterMap(topRouter) → {Object}
- Description:
- Generates a map for a given router
- Source:
Parameters:
Name |
Type |
Description |
topRouter |
Router
|
|
Returns:
The route map
-
Type
-
Object
(static) genericErrorHandler(error, req, res, next)
- Description:
- Generic error handling middleware for the API router
- Source:
Parameters:
Name |
Type |
Description |
error |
Error
|
|
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
next |
function
|
|
(async, static) handleInternalRoutes(req, res, next)
- Description:
- Handles restriction of routes marked as internal
- Source:
Parameters:
Name |
Type |
Description |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
next |
function
|
|
(static) mapHandler(topRouter) → {function}
- Description:
- Handler for returning an API map
- Source:
Parameters:
Name |
Type |
Description |
topRouter |
Router
|
|
Returns:
Middleware function
-
Type
-
function
(static) rootNotFoundHandler(req, res)
- Description:
- Middleware for handling 404 errors on the root router
- Source:
Parameters:
Name |
Type |
Description |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|