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

@noxfed/netacuity-node

v1.0.2

Published

node for netacuity

Downloads

6

Readme

netacuity-node

A tiny Node.js module for get request's IP address and retrieval geo information.

Installation

npm install @noxfed/netacuity-node --save

Getting Started

const netacuityNode = require('@noxfed/netacuity-node');

const clientInfo = await netacuityNode.getClientInfo(req, { databaseType: 3, netAcuityIp: NETACUITY });
// clientInfo:
/*
{
  'trans-id': 'DepUoE046v',
  ip: '118.26.73.210',
  country: 'chn',
  region: '###',
  city: '###',
  'conn-speed': '###',
  'country-conf': '5',
  'region-conf': '0',
  'city-conf': '0',
  'metro-code': '0',
  latitude: '0',
  longitude: '0',
  'country-code': '156',
  'region-code': '0',
  'city-code': '0',
  'continent-code': '4',
  'two-letter-country': 'cn'
}
*/
// on localhost you'll get ip as 127.0.0.1 and clientInfo['two-letter-country'] is '**'
// or ::1, ::ffff:127.0.0.1 if you're using IPv6 and clientInfo['two-letter-country'] also is '**'

As Connect Middleware

const netacuityNode = require('@noxfed/netacuity-node');
app.use(netacuityNode.mw())

app.use(function(req, res) {
    const clientInfo = await netacuityNode.getClientInfo(req, { databaseType: 3, netAcuityIp: NETACUITY });
    res.end(clientInfo);
});

How It Works

  1. netacuity-node based on request-ip

request-ip looks for specific headers in the request and falls back to some defaults if they do not exist.

The user ip is determined by the following order:

  1. X-Client-IP
  2. X-Forwarded-For (Header may return multiple IP addresses in the format: "client IP, proxy 1 IP, proxy 2 IP", so we take the the first one.)
  3. CF-Connecting-IP (Cloudflare)
  4. Fastly-Client-Ip (Fastly CDN and Firebase hosting header when forwared to a cloud function)
  5. True-Client-Ip (Akamai and Cloudflare)
  6. X-Real-IP (Nginx proxy/FastCGI)
  7. X-Cluster-Client-IP (Rackspace LB, Riverbed Stingray)
  8. X-Forwarded, Forwarded-For and Forwarded (Variations of #2)
  9. req.connection.remoteAddress
  10. req.socket.remoteAddress
  11. req.connection.socket.remoteAddress
  12. req.info.remoteAddress

If an IP address cannot be found, it will return null.

  1. node的项目一般都会有nginx反向代理,所以需要运维给nginx修改配置

Running the Tests

Make sure you have the necessary dev dependencies needed to run the tests:

npm install

Run the integration tests

npm test

Release Notes

See the wonderful changelog

To easily generate a new changelog, install github-changelog-generator then run npm run changelog.

License

The MIT License (MIT) - 2021