express-isdevice
v1.0.4
Published
express-isdevice uses a code from <https://npmjs.org/package/express-device> to detect devices
Downloads
8
Readme
#Express is Device
This module detects what kind of device is accessing the server. The algorithm of this module replicates part of the 'express-device' module therefore ensured for all merit to .
##Install
Just type the folowing command or put express-isdevice
in your package.json
$ npm install express-isdevice
##Ways to use
Currently you can use the proxy
function as a middleware in their requests. When the middleware proxy
is called, will add a variable in device
object req
.
Sample:
var device = require("express-isdevice");
app.get("/", [device.proxy], function(){});
// you can use multiples middlewares
app.get("/", [device.proxy, myFn], function(){});
##Get device info
To get the device just call req.device.is. <device>
, this returns true
or false
. The supported devices are:
- bot - for scripts and programs
- Desktop - PC, etc.
- empty - if not a 'user-agent' defined in the request
- phone - smartphones in general
- tablet - iPad, etc.
- tv - GoogleTV, etc.
- unknown - the 'user-agent' is unknown