Documentation / zerotal / index / ResponseBuilder
Class: ResponseBuilder
Defined in: packages/core/src/helpers/response.ts:39
Fluent builder returned by the redirect helpers for attaching flash data
(.withErrors(), .withSuccess(), …) to the response.
It implements PromiseLike<void> so that return back().withErrors(...)
compiles cleanly in handlers typed as async (ctx): Promise<void>: TypeScript
unwraps PromiseLike<void> in async context, making the builder void-compatible.
Implements
PromiseLike<void>
Constructors
Constructor
new ResponseBuilder(
ctx):ResponseBuilder
Defined in: packages/core/src/helpers/response.ts:42
Parameters
ctx
Returns
ResponseBuilder
Methods
with()
with(
key,value):this
Defined in: packages/core/src/helpers/response.ts:47
Flash an arbitrary key/value onto the next request's session.
Parameters
key
string
value
unknown
Returns
this
withErrors()
withErrors(
errors):this
Defined in: packages/core/src/helpers/response.ts:53
Flash a map of field errors under the errors key.
Parameters
errors
Record<string, string>
Returns
this
withSuccess()
withSuccess(
message):this
Defined in: packages/core/src/helpers/response.ts:58
Flash a success message under the success key.
Parameters
message
string
Returns
this
withError()
withError(
message):this
Defined in: packages/core/src/helpers/response.ts:63
Flash an error message under the error key.
Parameters
message
string
Returns
this
withWarning()
withWarning(
message):this
Defined in: packages/core/src/helpers/response.ts:68
Flash a warning message under the warning key.
Parameters
message
string
Returns
this
withInfo()
withInfo(
message):this
Defined in: packages/core/src/helpers/response.ts:73
Flash an info message under the info key.
Parameters
message
string
Returns
this
then()
then<
TResult1,TResult2>(onfulfilled?,onrejected?):PromiseLike<TResult1|TResult2>
Defined in: packages/core/src/helpers/response.ts:77
Attaches callbacks for the resolution and/or rejection of the Promise.
Type Parameters
TResult1
TResult1 = void
TResult2
TResult2 = never
Parameters
onfulfilled?
((value) => TResult1 | PromiseLike<TResult1>) | null
The callback to execute when the Promise is resolved.
onrejected?
((reason) => TResult2 | PromiseLike<TResult2>) | null
The callback to execute when the Promise is rejected.
Returns
PromiseLike<TResult1 | TResult2>
A Promise for the completion of which ever callback is executed.
Implementation of
PromiseLike.then