# @ra-data-simple-rest-backend/auth-koa

> Router for authentication and Middleware for authorization.

Latest version **0.0.7** (published 2019-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ra-data-simple-rest-backend/auth-koa
pnpm add @ra-data-simple-rest-backend/auth-koa
yarn add @ra-data-simple-rest-backend/auth-koa
bun add @ra-data-simple-rest-backend/auth-koa
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2019-04-09 |
| First published | 2019-03-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 192 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | yes |
| GitHub stars | 0 |
| Author | maruware |
| Maintainers | maruware |

## Links

- npm: https://www.npmjs.com/package/@ra-data-simple-rest-backend/auth-koa
- Repository: https://github.com/maruware/ra-data-simple-rest-backend
- Homepage: https://github.com/maruware/ra-data-simple-rest-backend#readme
- Issues: https://github.com/maruware/ra-data-simple-rest-backend/issues
- npm.io page: https://npm.io/package/@ra-data-simple-rest-backend/auth-koa

## Dependencies (5)

- [koa](https://npm.io/package/koa.md) ^2.7.0
- [koa-router](https://npm.io/package/koa-router.md) ^7.4.0
- [typescript](https://npm.io/package/typescript.md) ^3.3.4000
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [postinstall-build](https://npm.io/package/postinstall-build.md) ^5.0.3

## Recent versions

- 0.0.7 (latest) — 2019-04-09
- 0.0.6 — 2019-04-09
- 0.0.5 — 2019-04-09
- 0.0.4 — 2019-03-27
- 0.0.3 — 2019-03-27
- 0.0.2 — 2019-03-27
- 0.0.1 — 2019-03-27

## README

# Auth Koa

Router for authentication and Middleware for authorization.

## Install 

```
@ra-data-simple-rest-backend/auth-koa
```

## Usage

```ts
import Koa from 'koa'
import koaBody from 'koa-body'
import Router from 'koa-router'

import request from 'supertest'
import { buildAuth } from '@ra-data-simple-rest-backend/auth-koa'

const app = new Koa()
app.use(koaBody())

const admins = [{ username: 'takashi', password: 'my_password' }]
const auth = buildAuth('my secret', admins)

const router = new Router()
router.use('/auth', auth.router.routes(), auth.router.allowedMethods())

const apiRouter = new Router()
apiRouter.get('/sample', async ctx => {
    ctx.body = 'ok'
})
router.use(auth.middleware, apiRouter.routes(), apiRouter.allowedMethods())

app.use(router.routes()).use(router.allowedMethods())
```

---
_Source: https://npm.io/package/@ra-data-simple-rest-backend/auth-koa · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
