express-isdevice

express-isdevice uses a code from <https://npmjs.org/package/express-device> to detect devices

Usage no npm install needed!

<script type="module">
  import expressIsdevice from 'https://cdn.skypack.dev/express-isdevice';
</script>

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