Skip to content

Application

Anton edited this page Jul 25, 2019 · 39 revisions

The application is the instance created by the Goa class. It can provide the callback listener via the callback method, as well as start listening for connections itself. Application extends the EventEmitter class, so it's possible to listen on events, e.g.,

app.on('error', (err) => {
  // handle error
})

_goa.Application extends events.EventEmitter: The application interface.

Name Type & Description Default
proxy boolean -
Whether the server is running behind a proxy.
middleware* !Array<!_goa.Middleware> -
The array with middleware used on the server.
context* !_goa.Context -
The context object for each request.
request* !_goa.Request -
The request object for each request.
response* !_goa.Response -
The response object for each request.
env string development
The value from the NODE_ENV environment variable.
keys !(_goa.Keygrip | Array<string>) -
The keys for signing of the cookies.
silent boolean false
Whether to not log an error when it happens.
listen* function() -
Shorthand for: http.createServer(app.callback()).listen(...)
use* function(!_goa.Middleware): !_goa.Application -
Use the given middleware fn. Old-style middleware will be converted.
callback* function(): function(!http.IncomingMessage, !http.ServerResponse) -
Returns the request handler callback for node's native http/http2 server composed of the installed middleware.
createContext* function(!http.IncomingMessage, !http.ServerResponse) -
@private Initialize a new context.
onerror* function(!Error) -
@private Default error handler.
subdomainOffset number -
For example, if the domain is "tobi.ferrets.example.com": If app.subdomainOffset is not set, request.subdomains is ["ferrets", "tobi"]. If app.subdomainOffset is 3, request.subdomains is ["tobi"].
Clone this wiki locally