Skip to content

App Router Options

You may have noticed the {} as the constructor argument when instantiating apps and routers. That is the init options of those classes, allowing you to customize or set app / router level options for routes registered under it.

Why Router First

The App class extends Router, init options in Router are also available in App. Therefore, this guide has placed the base class Router at the beginning.

Router Options

This class is used for structuring big applications into multiple routers that is later included in the main app.

NameTypeDescriptionDefault
tags?string[]List of tags to be applied to all routes.[]
deprecated?booleanSet the deprecated status to all routes.false
includeInSchema?booleanSet to include or exclude all routes from the generated OpenAPI document.true
responses?Record<number, ResponseConfig>Additional response schemas to all routes, shown in the generated OpenAPI document.{ 422: ... }
defaultResponseClass?ResponseClassDefault response class of all routes.JSONResponse

App Options

Main application class. Extends Router.

All Router init options plus:

NameTypeDescriptionDefault
rootPath?stringRoot path of your application, a prefix that is not seen on the application but is seen by clients, like Worker Route Patterns and Swagger."/"
title?stringTitle of the application (OpenAPI)."Workery API"
description?stringDescription of the application (OpenAPI).""
version?stringVersion of the application (OpenAPI)."0.1.0"
tagsInfo?TagObject[]List of tag descriptions used by application routes.[]
servers?ServerObject[]List of connectivity information of the application (OpenAPI).[{ url: this.rootPath }]
contact?ContactObjectContact info of the application (OpenAPI)undefined
license?LicenseObjectLicense info of the application (OpenAPI)undefined
termsOfService?stringTerms of service info of the application (OpenAPI)undefined
openapiUrl?null | stringRoute path URL for serving the OpenAPI JSON document."/openapi.json"
swaggerUrl?null | stringRoute path URL for serving the Swagger interactive documentation."/docs"
redocUrl?null | stringRoute path URL for serving the ReDoc alternative documentation."/redoc"
middleware?Middleware<E>[]List of middleware applied to the application[]
exceptionHandler?ExceptionHandler<E>Exception handler when an exception or error has occured during requests.baseExceptionHandler