Skip to content

Commit

Permalink
add example for koa 2 to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
theverything committed Dec 30, 2016
1 parent 3c78e03 commit 7f66223
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]

An electrode plugin that enables stateless CSRF protection using [JWT](https://github.com/auth0/node-jsonwebtoken) in Electrode, Express, or Hapi applications.
An electrode plugin that enables stateless CSRF protection using [JWT](https://github.com/auth0/node-jsonwebtoken) in Electrode, Express, Hapi, or Koa 2 applications.

## Why do we need this module?

Expand Down Expand Up @@ -55,7 +55,7 @@ Others are optional and follow the [same usage as jsonwebtoken](https://github.c
* `noTimestamp`
* `headers`

This module can be used with either [Electrode](#electrode), [Express](#express), or [Hapi](#hapi).
This module can be used with either [Electrode](#electrode), [Express](#express), [Hapi](#hapi), or [Koa 2](#koa-2).

### Electrode

Expand Down Expand Up @@ -113,6 +113,24 @@ server.register({register: csrfPlugin, options}, (err) => {
});
```

### Koa 2

#### Example `app.js` configuration

```js
const csrfMiddleware = require("electrode-csrf-jwt").koaMiddleware;
const Koa = require("koa");

const app = new Koa();

const options = {
secret: "shhhhh",
expiresIn: 60
};

app.use(csrfMiddleware(options));
```

Built with :heart: by [Team Electrode](https://github.com/orgs/electrode-io/people) @WalmartLabs.

[npm-image]: https://badge.fury.io/js/electrode-csrf-jwt.svg
Expand Down

0 comments on commit 7f66223

Please sign in to comment.