Skip to main content

Class: RouteParams

Constructors

constructor

new RouteParams(app, template, data)

Parameters

NameType
appnull | App
templatestring
datastring

Defined in

packages/disploy/src/router/RouteParams.ts:7

Properties

app

Private app: null | App

Defined in

packages/disploy/src/router/RouteParams.ts:7


params

Private params: Record<string, string> = {}

Defined in

packages/disploy/src/router/RouteParams.ts:5

Methods

getParam

getParam(name): string

Get a parameter from the route.

Parameters

NameTypeDescription
namestringThe name of the parameter

Returns

string

A string representation of the parameter

Defined in

packages/disploy/src/router/RouteParams.ts:26


getUserParam

getUserParam(name): Promise<User>

Get a user from the route parameters.

Throws

If the User cannot be found or the parameter is not a valid user ID

Parameters

NameTypeDescription
namestringThe name of the parameter

Returns

Promise<User>

A User structure if the parameter is a valid user ID

Defined in

packages/disploy/src/router/RouteParams.ts:42


matchTemplate

Static matchTemplate(template, data): boolean

Match a template against a data string.

Example

'ping-:id' vs 'ping-123' => true
'ping-:id' vs 'ping-123-456' => false

Parameters

NameTypeDescription
templatestringThe template to match against
datastringThe data to match

Returns

boolean

Whether the data matches the template

Defined in

packages/disploy/src/router/RouteParams.ts:60