New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

connect-device-router

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-device-router

Connect middleware to route based on X-UA-Device

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

connect-device-router NPM version Build Status

Connect middleware to route based on X-UA-Device.

Use with varnish-devicedetect or connect-devicedetect to generate X-UA-Device headers.

Querystring overrides require connect.query or similar.

connect = require 'connect'
deviceDetect = require 'connect-devicedetect'
device = require 'connect-device-router'

desktopApp = connect()
  .use( ... )

mobileApp = connect()
  .use( ... )

app = connect()
  .use(connect.query())
  .use(deviceDetect())
  .use(device(phone: mobileApp))
  .use(desktopApp)

Or use per-route with express:

express = require 'express'
deviceRouter = require 'connect-device-router'

express()
  # map devices to handlers with chained middleware:
  .get '/foo',
    device 'phone', (req, res, next) ->
      # ...
    device 'desktop', (req, res, next) ->
      # ...
    (req, res, next) ->
      # default

  # or an object literal:
  .get '/', device
    phone: (req, res, next) -> # ...
    tablet: (req, res, next) -> # ...
  , (req, res, next) -> # default ...

  # or mix both styles:
  .get '/',
    device phone: (req, res, next) ->
      # ...
    device tablet: (req, res, next) ->
      # ...
    (req, res, next) ->
      # default ...

FAQs

Package last updated on 19 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc