express-caniuse
v1.0.2
Published
Express/Connect middleware for automatically determining browser capabilities
Downloads
1
Maintainers
Readme
express-caniuse
Express/Connect middleware for automatically determining browser capabilities
Description
This express middleware parses the user-agent of the incoming request, compares
it to the Can I use database and adds an additional
capabilities
object to the req
, showing which predetermined browser
features are supported. Use it for analytics or for conditional rendering, for
example!
Usage
npm install --save --production express-caniuse
var express = require('express');
var canIUseMiddleware = require('express-caniuse');
var app = express();
app.use(canIUseMiddleware({
features: [
'addeventlistener',
'setimmediate'
]
}));
app.get('hello', function (req, res, next) {
// Tested on Chrome 59.0 on OSX
console.log(req.capabilities)
// {
// 'addeventlistener': true,
// 'setimmediate': false
// }
});
If the browser could not be determined due to missing/unknown user-agent
header, req.capabilities
will be an empty object.
License
MIT © Matti Jokitulppo