jwt-flip-middleware

Express middleware, which if body is string converts from JWT => JSON if JSON => JWT


Keywords
jwt, flip, middleware, json, web, token, express
License
Unlicense
Install
npm install jwt-flip-middleware@1.0.1

Documentation

jwt-flip-middleware

Express middleware, which if body is string converts from JWT => JSON if JSON => JWT

How do I use it?

var jwt = require('./index')('mysecret', options);
    options is an object but optional!
    options = { jwt : {}, property : "decodeMe" } //defaults to decodeMe

app.post('/data', function(req, res, next){
    console.log('data');
    jwt(req, res, next);
});

DONE!

now if you post to /data with json without your property, it will be JWT encoded
{ "anythingBut-decodeMe" : "hello world" }

if you post /data with json with your property it will be decoded
{ "decodeMe" : "JWT-Token"}