npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

heroip

v1.0.2

Published

heroip: A Node.js utility for seamless IP address detection and geolocation. Easily retrieve the client's IP address and gather geolocation details, all in one package. Simplify IP-based operations in your applications with heroip.

Downloads

7

Readme

Introduction

heroip is a lightweight Node.js middleware and utility package that simplifies IP address lookup and geolocation based on incoming requests. This package is designed to seamlessly integrate into your Node.js applications to provide essential IP address information effortlessly.

Installation

Installing heroip is straightforward. You can add it to your Node.js project using npm, the package manager for Node.js:

  npm install heroip

Usage / Example

heroip simplifies the process of IP address detection and geolocation in your Express.js applications.

import express from "express";
import heroip, { lookup } from "heroip";

const app = express(); // Create an Express app

app.use(heroip); // Use heroip middleware for IP info

app.get("/", (req, res) => {
  const { ipInfo } = req; // Access IP information from the request object
  res.json(ipInfo); // Respond with IP details as JSON
});

const port = process.env.PORT || 3000; // Set the server port
app.listen(port, () => {
  console.log(`Server is running on port ${port}`); // Start the server
});

const ipAddress = "8.8.8.8"; // IP address to look up
const ipDetails = lookup(ipAddress); // Use lookup function to get IP details

console.log(ipDetails); // Log the IP details

Why Use heroip?

The heroip package offers several compelling reasons to simplify IP address lookup and geolocation in your Node.js applications:

  1. Ease of Use: With just a few lines of code, you can effortlessly retrieve detailed information about incoming IP addresses. The heroip middleware seamlessly integrates into your Express.js applications, making IP data readily available.

  2. Improved Functionality: By gaining access to the IP details of incoming requests, you can enhance your application's functionality. This can include personalizing content, enhancing security measures, or building analytics features.

  3. Flexibility: The package provides both middleware and a standalone lookup function, allowing you to choose the approach that best suits your application's needs. Use the middleware to automatically populate IP information in your request objects or manually look up IP details when required.

  4. Underlying Libraries: heroip leverages well-established libraries such as request-ip and geoip-lite to ensure accuracy and reliability in IP address handling and geolocation.

  5. Open Source: This package is open-source and available under the MIT License, making it freely accessible and customizable for your projects.

Whether you're building a location-based service, enhancing user experiences, or adding security layers, heroip simplifies the process of working with IP addresses, enabling you to focus on your application's core functionality.

Explore the documentation for detailed usage instructions and leverage heroip to unlock the potential of IP address data in your Node.js applications.

Acknowledgments

We would like to express our gratitude to the creators and maintainers of the following packages and resources that have contributed to the functionality and capabilities of heroip:

  • request-ip: A package that provides middleware for extracting client IP addresses from Express.js requests.

  • geoip-lite: A package for performing lightweight geolocation lookups based on IP addresses.

These packages have been instrumental in making IP address detection and geolocation easy and efficient in heroip. We appreciate the hard work and dedication of their respective maintainers.

Author

heroip is developed and maintained by Nazmul Hridoy.

Feel free to reach out to the author for questions, feedback, or contributions related to the package. Contributions and suggestions are always welcome and appreciated.

License

heroip is licensed under the MIT License.