commit 4e0f0f3f7e113cadbd2230d66c7e3c588cef2c60 Author: b1ek Date: Sat Mar 18 21:32:08 2023 +1000 base commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f846c68 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +package-lock.json +yarn.lock diff --git a/index.js b/index.js new file mode 100644 index 0000000..87e500e --- /dev/null +++ b/index.js @@ -0,0 +1,16 @@ +const Browser = require('which-browser'); +// const express = require('express'); + +/** + * + * @param {express.Request} req + * @param {express.Response} res + * @param {*} next + */ +function handler(req, res, next) { + const browser = new Browser(req.headers); + req.browser = browser; + next(); +} + +module.exports = handler; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ecc466c --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "express-browser", + "version": "1.0.0", + "description": "Detect client's browser in Express.JS", + "main": "index.js", + "author": "b1ek", + "license": "MIT", + "dependencies": { + "express": "^4.18.2", + "which-browser": "^0.7.0" + } +}