@morojs/moro


@morojs/moro / MoroRouter

Class: MoroRouter

Defined in: src/core/routing/create-router.ts:24

Standalone router. Collects routes and middlewares, then mounts them onto an app at a given prefix via app.use(prefix, router) or router.mount(app, prefix).

Example

const r = createRouter();
  r.get('/users', getUsers);
  r.post('/users', createUser);
  app.use('/api', r);

Constructors

Constructor

new MoroRouter(): MoroRouter

Returns

MoroRouter

Properties

_morojsRouter

readonly _morojsRouter: true = true

Defined in: src/core/routing/create-router.ts:26

Internal

— tag used by app.use(path, router) to detect router instances.

Methods

all()

all(path, ...handlers): this

Defined in: src/core/routing/create-router.ts:58

Register the same handler(s) for all HTTP methods on the path.

Parameters

path

string

handlers

...any[]

Returns

this


delete()

delete(path, ...handlers): this

Defined in: src/core/routing/create-router.ts:44

Parameters

path

string

handlers

...any[]

Returns

this


get()

get(path, ...handlers): this

Defined in: src/core/routing/create-router.ts:35

Parameters

path

string

handlers

...any[]

Returns

this


head()

head(path, ...handlers): this

Defined in: src/core/routing/create-router.ts:50

Parameters

path

string

handlers

...any[]

Returns

this


mount()

mount(app, prefix?): void

Defined in: src/core/routing/create-router.ts:83

Mount all collected routes onto app at the given prefix.

Parameters

app

any

prefix?

string = ''

Returns

void


options()

options(path, ...handlers): this

Defined in: src/core/routing/create-router.ts:53

Parameters

path

string

handlers

...any[]

Returns

this


patch()

patch(path, ...handlers): this

Defined in: src/core/routing/create-router.ts:47

Parameters

path

string

handlers

...any[]

Returns

this


post()

post(path, ...handlers): this

Defined in: src/core/routing/create-router.ts:38

Parameters

path

string

handlers

...any[]

Returns

this


put()

put(path, ...handlers): this

Defined in: src/core/routing/create-router.ts:41

Parameters

path

string

handlers

...any[]

Returns

this


use()

use(...middleware): this

Defined in: src/core/routing/create-router.ts:30

Parameters

middleware

...Middleware[]

Returns

this