Express middleware which extract sort from request
request : /test?sort=name,username&desc=username
result : req.happyRest.sort = ["name" , "-username"]
npm install happyrestsort
like all others Express middleware :
var express = require('express') , happyRestSort = require('happyRestSort');
var app = express();
app.use(extractSort());
app.use('/test?sort=name,username&desc=username, function (req, res, next) { console.log('Sort:', req.happyRest.sort); next(); });
var express = require('express') , happyRestSort = require('happyRestSort');
var router = express.Router();
router.get('/test?sort=name,username&desc=username', extractSort(), function (req, res, next) { console.log('Sort:', req.happyRest.sort); next(); })