Members
Type:
AppManager
see affiliated serviser-config
npm package
Type:
Config
Type:
String
Type:
ResourceManager
Type:
Service
one of AppStatus
enum
Type:
String
Constructor
- appManager
- Type:
AppManager
- config
- Type:
Config
module
- options
- Type:
Object
- name
- Type:
String
app's name
- validator optional
- Type:
Object
Ajv validator initialization options
- schemas optional
- Type:
Object
orArray
list of globally accessible schema definitions
Parameters:
Fires:
Methods
- options
- Type:
Object
- public optional
- Type:
String
- version optional
- Type:
String
- url
- Type:
String
- port|socket optional
- Type:
Integer
orString
- event
- Type:
String
- callback
- Type:
function
- endpoint optional
- Type:
String
- callback optional
- Type:
function
- self
Router
Parameters:
Router
Promise
shutdown underlying net socket. if not running, resolved Promise will be returned
Returns:Promise
Route
Ajv
Ajv
validator instance
Parameters:
Boolean
registeres event listener.
overrides event emmiter implementation
Parameters:
Boolean
AppInterface
bind application-level middleware that will be run before Route
's
middleware stack
Parameters:
AppInterface
Events
- error
- Type:
Error
- err
- Type:
RequestError
- res
- Type:
http.ServerResponse
response
- app
- Type:
AppInterface
- app
- Type:
AppInterface
- app
- Type:
AppInterface
- app
- Type:
AppInterface
- status
- Type:
String
see
AppStatus
enum for available option values- err
- Type:
Error
- errorHandler
- Type:
function
callback function
fires each time an unexpected internal Error is encoutered.
When the Error is catched in the application space, the Error is coerced
to ServiceError
type which is safe to respond with.
Internal listener is binded at initialization time which logs all received
Errors with the serviser-logger package.
AppInterface#status
is updated with the first internal error setting the Application to error
state.
Properties:
By default an App
handles all "expected" & unexpected Errors automatically
and responds to a request accordingly.
By pushing a listener to this event, you can define custom user
error processing logic and respond to the request manually.
Listeners of this event are executed asynchronously - Promises
are supported.
Properties:
Example:
app.on('error-response', function(err, res) {
//pseudocode:
//renders html view and sends html response instead of default json response
return res.render('error', err); //returns a Promise
});
emitted after app route definitions are assembled into a single function and binded to internal http[s] server.
Properties:
emitted after internal initialization of the App instance and before
AppInterface#event:pre-build
and AppInterface#event:post-build
events.
This is the time to register application wide middlewares which get executed before
the main route implementation.
Properties:
emitted before app route definitions are assembled into a single function.
Properties:
emitted before internal initialization of the App instance which will validate configuration, setup default application wide response headers and error handling middlewares
Properties:
emitted once each time after status change.
Once you get AppStatus#ERROR
status, the App's status can NOT
be changed thus no more status-changed
events will be emitted.
Properties:
Is emitted before a response to a request is sent and allows to convert
an unknown error (an error which is not instanceof RequestError
and at the same time is not dirrect instanceof Error)
to RequestError
which will be then processed in place of the original unknown error object.
if no listener is present all unknown errors will be automatically converted to ServiceError
Properties:
Example:
app.on('unknown-error', function(err, errorHandler) {
if (err instanceof SequelizeUniqueConstraintError) {
return errorHandler(new RequestError('Entity already exists'));
}
//hand back the error processing to the application
return errorHandler(err);
});