Command line interface.
Application config.
Default stash values.
Detect if the application has been imported and disable the command line interface if it has.
Format for HTTP exceptions ("html", "json", or "txt").
Application home directory.
Application hooks.
Application logger.
Maximum request body size in bytes, defaults to 16777216 (16 MiB). Requests exceeding the limit are answered
with 413 when the body is read. Can also be changed for individual requests with ctx.req.maxMessageSize.
MIME types.
Operating mode for application. Defaults to the value of the NODE_ENV environment variable or development.
Storage for user defined models.
Application renderer.
Application router.
Rotating secret passphrases used for signed cookies and the like.
Encrypted cookie based session manager.
Static file server.
HTTP/WebSocket user-agent.
JSON schema validator.
Add a helper.
// Render response with header
app.addHelper('renderWithHeader', async (ctx, ...args) => {
ctx.res.set('X-Mojo', 'I <3 mojo.js!');
await ctx.render(...args);
});
// Render response with header using nested helper
app.addHelper('renderWith.header', async (ctx, ...args) => {
ctx.res.set('X-Mojo', 'I <3 mojo.js!');
await ctx.render(...args);
});
Generate route matching any of the listed HTTP request methods or all.
// Route with pattern and destination
app.any('/user').to('User#whatever');
// Route with HTTP methods, pattern, restrictive placeholders and destination
app.any(['DELETE', 'PUT'], '/:foo', {foo: /\w+/}).to('Foo#bar');
// Route with pattern, name and destination
app.any('/:foo').name('foo_route').to('Foo#bar');
// Route with pattern, condition and destination
app.any('/').requires({agent: /Firefox/}).to('Foo#bar');
// Route with pattern and a closure as destination
app.any('/:foo', async ctx => ctx.render({text: 'Hello World!'}));
Create a context for application.
Create a mock context for application. Very useful for testing helpers.
Create a new mock user-agent for application.
Optionaloptions: UserAgentOptionsOptionalserverOptions: ServerOptionsCreate a new test user-agent for application.
Optionaloptions: TestUserAgentOptionsOptionalserverOptions: ServerOptionsYour main hook into the application, it is a shortcut for the app:start hook and runs during application
startup. You can use it to perform tasks like preparing database connections.
Generate route for a nested route with its own intermediate destination.
Warmup the cache, usually called automatically.
Generate route matching only WebSocket handshake requests.
Application class.