Express user-agent Middleware
Express middleware to parse user-agent header
Install
npm i express-ua-middleware
yarn add express-ua-middleware
Use
This is a middleware to provide parsed user agent header, to use simply, import module, then use it on express.use
method.
const userAgent = require("express-ua-middleware");
const express = require("express");
const server = express();
server.use(userAgent);
server.get("/", (req, res) => {
console.log(req.userAgent);
})
Or you can use as parser, with method userAgentFromString
server.get("/", (req, res) => {
console.log(req.userAgentFromString(req.headers["user-agent"]));
})
Contributing
To contribute with the project, open a issue on Github or create a Pull Request