client-request-inspector

1.0.0 • Public • Published

client-request-inspector

npm npm NPM Coverage

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"
    }
}

Social Links

LinkedIn GitHub Repo

Package Sidebar

Install

npm i client-request-inspector

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

66.2 MB

Total Files

14

Last publish

Collaborators

  • iheb_mejri