0.1.0 • Published 7 years ago

trek-csrf v0.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

trek-csrf

CSRF Tokens Middleware for Trek.js

Installation

$ npm install trek-csrf --save

Examples

'use strict'

const Engine = require('trek-engine')
const sessions = require('trek-sessions')
const bodyParser = require('trek-body-parser')
const csrf = require('trek-csrf')

async function start () {
  const app = new Engine()

  app.use(sessions())

  app.use(bodyParser())

  app.use(csrf())

  app.use(ctx => {
    ctx.res.body = ctx.store.get('csrf')
  })

  app.on('error', (err, ctx) => {
    console.log(err)
  })

  app.run(3000)
}

start().catch(console.log)

API

csrfWithConfig({
  key: 'csrf',
  tokenLookup: 'header:X-CSRF-Token',
  ignoreMethods: ['GET', 'HEAD', 'OPTIONS', 'TRACE'],
  // https://github.com/pillarjs/csrf#new-tokensoptions
  tokenOptions: undefined
})

Badges

Build Status codecov npm.io


fundon.me  ·  GitHub @fundon  ·  Twitter @_fundon

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago