1.0.0 • Published 5 months ago

client-request-inspector v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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:

PropertyTypeDescription
ipstringIP address of the client
browserstringUser agent string identifying the browser
locationObjectObject 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