trek-method-override

0.1.1 • Public • Published

trek-method-override

Method Overrider Middleware for Trek.js

Installation

$ npm install trek-method-override --save

Examples

'use strict'
 
const Engine = require('trek-engine')
const bodyParser = require('trek-body-parser')
const methodOverride = require('trek-method-override')
 
async function start () {
  const app = new Engine()
 
  app.use(bodyParser())
 
  app.use(methodOverride())
 
  app.use(ctx => {
    ctx.res.body = {
      method: ctx.req.method,
      originalMethod: ctx.req.originalMethod
    }
  })
 
  app.on('error', (err, ctx) => {
    console.log(err)
  })
 
  app.run(3000)
}
 
start().catch(console.log)

API

methodOverride({
  methods: ['POST'],
  tokenLookup: 'header:X-HTTP-Method-Override'
})

Badges

Build Status codecov


fundon.me  ·  GitHub @fundon  ·  Twitter @_fundon

Package Sidebar

Install

npm i trek-method-override

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • fundon