@absolunet/ioc2.1.0

View on GitHub

StaticController

Controller that handle static content response.

Extends

Members

(static) dependencies :Array.<string>

Source:
Class dependencies: ['file'].

writeStreamLineHandler :function

Source:
Inherited From:
Command streaming interceptor handler.

isStreaming :boolean

Source:
Inherited From:
Indicates if the response is currently streaming.

request :request

Source:
Inherited From:
Express request.

response :response

Source:
Inherited From:
Express response.

Methods

handle(defaults)

Source:
Handle redirection.
Parameters:
Name Type Description
defaults Object The default values.
Returns:
The response.
Type
*

prepareHandling(app, request, response)

Source:
Inherited From:
Prepare request handling.
Parameters:
Name Type Description
app container.Container The current container instance.
request request The current request instance.
response response The current response instance.

view(view, data)

Source:
Inherited From:
Send HTML response.
Parameters:
Name Type Description
view string The view name.
data * The view-model data.
Returns:
The response instance.
Type
response

json(object)

Source:
Inherited From:
Send JSON response.
Parameters:
Name Type Description
object string | number | boolean | object The JSON value to send.
Returns:
The response instance.
Type
response

dump(…parameters)

Source:
Inherited From:
Dump parameters in the current response.
Parameters:
Name Type Attributes Description
parameters * <repeatable>
The dumped values.

(async) stream(handler)

Source:
Inherited From:
Send a stream response. Ends the request when the handler resolves.
Parameters:
Name Type Description
handler function The stream handler.
Returns:
The async process promise.
Type
Promise

writeStreamLine(line)

Source:
Inherited From:
Write line in the stream response.
Parameters:
Name Type Description
line string The line to stream into the response.
Returns:
The current controller instance.
Type
http.controllers.Controller

streamCommand(command)

Source:
Inherited From:
Send a stream response from command output.
Parameters:
Name Type Description
command string | Array.<string> The command string.
Returns:
The async process promise.
Type
Promise

(async) runCommand(command, handleropt)

Source:
Inherited From:
Run command. Handle output if an handler is provided.
Parameters:
Name Type Attributes Default Description
command string | Array.<string> The command string.
handler function | null <optional>
null The handler that will received printed data after command will have run.
Returns:
The async process promise.
Type
Promise

validate(validationClosure)

Source:
Inherited From:
Validate the current request body against the given schema.
Parameters:
Name Type Description
validationClosure function The validation callback that returns the validation schema.

redirect(to, permanentopt)

Source:
Inherited From:
Redirect to the given URL with the appropriate redirection code.
Parameters:
Name Type Attributes Default Description
to string The URL to redirect to.
permanent boolean <optional>
false Indicates that the redirection response should flag a permanent redirection.
Returns:
The current response instance.
Type
response

permanentRedirect(to)

Source:
Inherited From:
Redirect to the given URL permanently.
Parameters:
Name Type Description
to string The URL to redirect to.
Returns:
The current response instance.
Type
response

status(status)

Source:
Inherited From:
Set response status.
Parameters:
Name Type Description
status number The HTTP status code.
Returns:
The current controller instance.
Type
http.controllers.Controller

throwWithStatus(status)

Source:
Inherited From:
Set response status and throw an HTTP error that reflects the given status.
Parameters:
Name Type Description
status number The HTTP status code.
Throws:
The corresponding HTTP error based on the HTTP status code.
Type
http.exceptions.HttpError

ok()

Source:
Inherited From:
Set 200 OK status.
Returns:
The current controller instance.
Type
http.controllers.Controller

created()

Source:
Inherited From:
Set 201 Created status.
Returns:
The current controller instance.
Type
http.controllers.Controller

accepted()

Source:
Inherited From:
Set 202 Accepted status.
Returns:
The current controller instance.
Type
http.controllers.Controller

noContent()

Source:
Inherited From:
Set 204 No Content status.
Returns:
The current controller instance.
Type
http.controllers.Controller

badRequest()

Source:
Inherited From:
Set 400 Bad Request status.
Returns:
The current controller instance.
Type
http.controllers.Controller

unauthorized()

Source:
Inherited From:
Set 401 Unauthorized status.
Returns:
The current controller instance.
Type
http.controllers.Controller

forbidden()

Source:
Inherited From:
Set 403 Forbidden status.
Returns:
The current controller instance.
Type
http.controllers.Controller

notFound()

Source:
Inherited From:
Set 404 Not Found status.
Returns:
The current controller instance.
Type
http.controllers.Controller

methodNotAllowed()

Source:
Inherited From:
Set 405 Method Not Allowed status.
Returns:
The current controller instance.
Type
http.controllers.Controller

timeout()

Source:
Inherited From:
Set 408 Timeout status.
Returns:
The current controller instance.
Type
http.controllers.Controller

teapot()

Source:
Inherited From:
Set 418 I'm A Teapot status.
Returns:
The current controller instance.
Type
http.controllers.Controller