# trek-csrf

> CSRF Tokens Middleware for Trek.js

Latest version **0.1.0** (published 2017-04-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install trek-csrf
pnpm add trek-csrf
yarn add trek-csrf
bun add trek-csrf
```

## 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.1.0 |
| Published | 2017-04-13 |
| First published | 2017-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Fangdun Cai |
| Maintainers | fundon |
| Keywords | csrf, tokens, middleware, trek |

## Links

- npm: https://www.npmjs.com/package/trek-csrf
- Repository: https://github.com/trekjs/csrf
- Homepage: https://github.com/trekjs/csrf#readme
- Issues: https://github.com/trekjs/csrf/issues
- npm.io page: https://npm.io/package/trek-csrf

## Dependencies (1)

- [csrf](https://npm.io/package/csrf.md) ^3.0.6

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2017-04-13
- 0.0.2 — 2017-02-23
- 0.0.1 — 2017-02-08

## README

# trek-csrf

CSRF Tokens Middleware for Trek.js


## Installation

```
$ npm install trek-csrf --save
```


## Examples

```js
'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

```js
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](https://travis-ci.org/trekjs/csrf.svg?branch=master)](https://travis-ci.org/trekjs/csrf)
[![codecov](https://codecov.io/gh/trekjs/csrf/branch/master/graph/badge.svg)](https://codecov.io/gh/trekjs/csrf)
![](https://img.shields.io/badge/license-MIT-blue.svg)

---

> [fundon.me](https://fundon.me) &nbsp;&middot;&nbsp;
> GitHub [@fundon](https://github.com/fundon) &nbsp;&middot;&nbsp;
> Twitter [@_fundon](https://twitter.com/_fundon)

---
_Source: https://npm.io/package/trek-csrf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
