This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@donutteam/koa-router
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

Koa Router

A class for creating Koa middlewares that route requests based on the request URL.

This middleware, at this time, is essentially a wrapper for @koa/router that simply serves to offer the same functionality in a form factor similar to other Donut Team Koa middlewares.

Note: There are some features of @koa/router that are not convenient to use with this package, such as nested routers, that we don't personally care about when developing Donut Team web services.

Installation

Install the package with NPM:

npm install @donutteam/koa-router

Usage

To use this class, simply instantiate an instance and add it to your Koa stack:

import Koa from "koa";

import { RouterMiddleware } from "@donutteam/koa-router";

const app = new Koa();

// You may want to export the router and register your
// routes within the files that actually contain their code
export const routerMiddleware = new RouterMiddleware();

// Be sure to add the execute function on the instance
// and NOT the instance itself
app.use(routerMiddleware.execute);

Options

koaRouter

Options for the underlying @koa/router.

See this page for more details.

Methods

execute

The middleware function to be passed to Koa.

router

The router object is an instance of @koa/router so all of the same methods apply there.

See this page for more details.

License

MIT

Package Sidebar

Install

npm i @donutteam/koa-router

Weekly Downloads

0

Version

3.0.0

License

MIT

Unpacked Size

9.16 kB

Total Files

7

Last publish

Collaborators

  • duckdotexe