Socket
Socket
Sign inDemoInstall

nest-request-ip

Package Overview
Dependencies
244
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nest-request-ip

Nest Request IP is a convenient Nest.js module that allows you to effortlessly retrieve information from HTTP requests, including client IP addresses, user agents, browsers, and operating systems. With this module, you can enhance your Nest.js application


Version published
Weekly downloads
76
decreased by-10.59%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Nest Request IP

Nest Request IP is a convenient Nest.js module that allows you to effortlessly retrieve information from HTTP requests, including client IP addresses, user agents, browsers, and operating systems. With this module, you can enhance your Nest.js application's functionality by gaining insights into the characteristics of incoming requests.

Features

  • Get IP from HTTP requests
  • Discover agent, browser, device, OS, etc.
  • Get city, country, region, timezone from IP

Installation

npm install nest-request-ip --save

Usage

app.module.ts

import { Module } from "@nestjs/common";
import { RequestIpModule } from "nest-request-ip";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";

@Module({
  imports: [
    RequestIpModule.forRoot({
      localIpAddress: "76.76.21.123", // this ip is used when the request is local
    }),
  ],
  controllers: [AppController],
})
export class AppModule {}

app.controller.ts

import { Controller, Get, Req } from "@nestjs/common";
import { Request } from "express";
import {
  GetClientIp,
  GetClientAgent,
  GetClientBrowser,
  GetClientSystem,
} from "nest-request-ip";

@Controller()
export class AppController {
  @Get()
  getHello(@GetClientIp() ip: ClientInfo) {
    return ip;
  }

  @Get("agent")
  getAgent(@GetClientAgent() agent: string) {
    return agent;
  }

  @Get("browser")
  getBrowser(@GetClientBrowser() browser: string) {
    return browser;
  }

  @Get("system")
  getSystem(@GetClientSystem() system: string) {
    return system;
  }
}

License

MIT licensed.

FAQs

Last updated on 23 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc