client-request-inspector
v1.0.0
Published
A Node.js library designed for efficient server-side extraction of client request data, providing easy access to client information such as IP address, browser type and location
Downloads
24
Maintainers
Readme
client-request-inspector
Overview
client-request-inspector
is a Node.js library designed for efficient server-side extraction of client data,
providing easy access to information such as IP address
, browser type
, and location
to enhance the development experience for seamless web applications.
Features
- Server-side client data extraction
- Support for IP address, browser type, and location
- Designed for use in web development projects
- Seamless integration with Express.js
[!TIP] To test the lib locally use ngrok
Installation
You can install client-request-inspector
via npm or yarn.
npm install client-request-inspector
# or
yarn add client-request-inspector
Usage
const express = require('express');
const app = express();
const port = 3000;
// Import the library
const {clientInspector} = require('client-request-inspector');
app.get('/', async (req, res) => {
// use client inspector
const data = await clientInspector(req);
res.send(data);
});
app.listen(port, () => {
console.log(`Server is listening at http://localhost:${port}`);
});
Return Type Format
The clientInspector
function returns an object with the following format:
| Property | Type | Description |
|:----------:|:-------------:|:---------------------------------------------------------------------------------:|
| ip | string
| IP address of the client |
| browser | string
| User agent string identifying the browser |
| location | Object
| Object containing location information (isoCode, country, continent and timezone) |
Exemple:
{
ip: "197.2.183.18",
browser: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0",
location: {
isoCode: "TN",
country: "Tunisia",
continent: "Africa",
timeZone: "Africa/Tunis"
}
}