# koa-router-decorator

> Use decorator for koa-router

Latest version **1.0.1** (published 2017-05-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-router-decorator
pnpm add koa-router-decorator
yarn add koa-router-decorator
bun add koa-router-decorator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-05-14 |
| First published | 2017-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Lxxyx |
| Maintainers | lxxyx |
| Keywords | koa, koa-router, decorator |

## Links

- npm: https://www.npmjs.com/package/koa-router-decorator
- Repository: https://github.com/Lxxyx/koa-router-decorator
- Homepage: https://github.com/Lxxyx/koa-router-decorator#readme
- Issues: https://github.com/Lxxyx/koa-router-decorator/issues
- npm.io page: https://npm.io/package/koa-router-decorator

## Dependencies (1)

- [koa-router](https://npm.io/package/koa-router.md) ^7.1.1

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-05-14
- 1.0.0 — 2017-05-14

## README

![build status](https://travis-ci.org/Lxxyx/koa-router-decorator.svg?branch=master)

# Intro
Use decorator for koa.

Support typescript with experimentalDecorators, but not test on javascript.

## Usage

First, in your `tsconfig.json`, set `experimentalDecorators` to `true`.

```js
import Route from 'koa-router-decorator'
import Koa from 'koa'

@Route.init()
class TestRoute {
  @Route.get('/')
  async index (ctx: Koa.Context) {
    const result = await Promise.resolve(1)
    ctx.body = result
  }
}
const testRoute = new TestRoute()

const app = new Koa()
app.use((testRoute as any).routes())

const res = await supertest(app.listen())
  .get('/')
  .expect(200)

t.true(res.text === '1')

```

---
_Source: https://npm.io/package/koa-router-decorator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
