Route
Variable: Route
constRoute: {(value,context):any; (...args): (value,context) =>any; }
Defined in: packages/core/src/rest/irest.ts:61
Bind a class method to an HTTP route at the service's base URL.
Prefer @Operation. Operations plug into REST, GraphQL, and gRPC with
a single declaration and give you request/response schema generation for
free. @Route is the escape hatch for endpoints that don't fit the
operation model (static assets, JWKS, Accept-based content negotiation,
server-sent events, manual streaming, etc.) — anything where you need raw
access to WebContext and the operation abstraction would get in the way.
Routes are read by Router.discoverRoutes() after service init and
registered on the router with the same semantics as a manual
this.addRoute(...) call. route is resolved relative to the service's
url parameter when it starts with . (".", "./me", "./email/{email}").
Call Signature
(
value,context):any
Parameters
value
any
context
ClassMethodDecoratorContext
Returns
any
Call Signature
(...
args): (value,context) =>any
Parameters
args
...[string, HttpMethodType | HttpMethodType[], OpenAPIWebdaDefinition]
Returns
(value, context) => any
Param
route
URL pattern, e.g. ".", "./me", "./{id}/children"
Param
methods
HTTP verb or list; defaults to ["GET"]
Param
openapi
OpenAPI PathItemObject fragment for this method
Example
class JwksService extends Service {
// Raw route — JWKS content-type isn't a natural fit for @Operation
@Route(".", ["GET"], { get: { operationId: "getJWKS" } })
async serveJWKS(ctx: OperationContext) { … }
}