Skip to content

Commit

Permalink
fix(typings): remove koa context modification
Browse files Browse the repository at this point in the history
BREAKING CHANGE: koa context modification removed, fix typings, add
default export

BREAKING CHANGE: koa context modification removed
  • Loading branch information
rvboris committed Jan 24, 2020
1 parent 1b06333 commit ae22dbb
Show file tree
Hide file tree
Showing 6 changed files with 1,033 additions and 973 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,31 @@ koa-useragent
### Usage overview

```js
const koa = require('koa'),
const app = koa.app()
const koa = require('koa');
const app = koa.app();
const { userAgent } = require('koa-useragent');

app.use(userAgent);

app.use(async (ctx, next) {
console.log(require('util').inspect(ctx.userAgent));
console.log(require('util').inspect(ctx.userAgent));
});

app.listen(3000);
```

### Typescript example

```ts
import Koa, { BaseContext } from 'koa';
import { userAgent, UserAgentContext } from 'koa-useragent';

const app = new Koa();

app.use(userAgent);

app.use<BaseContext, UserAgentContext>((ctx) => {
console.log(require('util').inspect(ctx.userAgent));
});

app.listen(3000);
Expand Down
Loading

0 comments on commit ae22dbb

Please sign in to comment.