View Source Configuration

There's a lot of parameters that can be configured in Nova. This document will try to explain them all.

Cowboy configuration

Nova uses Cowboy as the webserver. Cowboy is a very flexible webserver and Nova tries to expose as much of this flexibility as possible. This means that you can configure Cowboy in a lot of different ways. The configuration is done in the nova-application under cowboy_configuration-key in your sys.config.

KeyDescriptionValueDefault
stream_handlersStream handlers are used to handle streaming requests. You can configure multiple stream handlers. Read more in the subsection Stream handlerslist()[nova_stream_h, cowboy_compress_h, cowboy_stream_h]
middleware_handlersMiddleware handlers are used to handle middleware requests. You can configure multiple middleware handlers. Read more in the subsection Middleware handlerslist()[nova_router, nova_plugin_handler, nova_security_handler, nova_handler, nova_plugin_handler]
optionsCowboy options. Read more in the subsection Cowboy optionsmap()#{compress => true}
ipIP to bind totuple{0, 0, 0, 0}
portPort to bind tointeger()8080
use_sslIf SSL should be usedboolean()false
ssl_optionsTransport options for SSL. Nova uses ranch_ssl module so read about available options on their page.ranch_ssl:opts()#{cert => "/path/to/cert.pem", key => "/path/to/key.pem"}
ssl_portPort to bind to when using SSLinteger()8443
ca_certPath to CA-cert Deprecated since 0.10.3 - Read with ssl_optionsstring()undefined
certPath to cert Deprecated since 0.10.3 - Replaced with ssl_optionsstring()undefined

Nova specific configurations

Following parameters should be defined under the nova-key in your sys.config.

KeyDescriptionValue
use_persistent_termUse persistent_term module to store routing treeboolean()
use_stacktraceIf Nova should include stacktrace in error-pagesboolean()
render_error_pagesIf Nova should render error-pages for HTML-requestboolean()
use_sessionsTurn off/on support for sessionsboolean()
session_managerSpecifify a module to use as the session manager. Defaults to nova_session_etsatom()
use_strict_routingIf the routing module should work under the strict mode. Using strict mode will cause errors if non-deterministic paths are detected. This is a beta-function so use with caution.boolean()
bootstrap_applicationDefine which application to bootstrap with Nova. This should be the name of your application.atom()
cowboy_configurationIf you need some additional configuration done to Cowboy this is the place. Check nova_sup module to learn which keys that can be defined.map()

Application parameters

These parameters can be specified in your main application (Eg the one you've specified in the bootstrap-section).

KeyDescriptionValue
json_libJSON lib to use. Read more in the subsection Configure json libatom()

| watchers | Watchers are external programs that will run together with Nova. Watchers are defined as list of tuples where the tuples is in format {Command, ArgumentList} (Like [{my_app, "npm", ["run", "watch"], #{workdir => "priv/assets/js/my-app"}}]) | [{string(), string()}] | [{atom(), string(), map()}] | [{atom(), string(), list(), map()}] |

Configure json_lib

One can configure which json library to use for encoding/decoding json structures. The module defined for this should expose two different functions:

encode(Structure) -> binary() | iolist()

decode(JsonString) -> {ok, Structure}

Handling errors in Nova

Nova will by default render a error page if an error occurs. This page will be rendered using the nova_error-template. This template can be overridden by defining a template with the same name in your application. By defauly Nova outputs a lot of information, including the stacktrace. This might not be a good approach in production. To turn off stacktraces in production you can add the following to your sys.config:

{nova, [{render_error_pages, false}]}

This will exclude stacktrace from the error page.

Note Nova is aware about which accept-headers the request is sent with and will respond with the correct content-type. If the request is sent with application/json Nova will respond with a JSON-structure instead of a HTML-page.