From 7f662239b1cb5a8befd77bdeaad4c0358f3dfe7d Mon Sep 17 00:00:00 2001 From: Jeffrey Horn Date: Thu, 29 Dec 2016 21:13:32 -0800 Subject: [PATCH] add example for koa 2 to readme --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c08ca13..df16b96 100644 --- a/README.md +++ b/README.md @@ -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? @@ -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 @@ -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