Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/p0vidl0/nestjs-real-ip
A concise decorator for retrieving an IP address from http request with Nest.js controller method.
https://github.com/p0vidl0/nestjs-real-ip
ip ip-address nest nestjs real-ip typescript
Last synced: 3 months ago
JSON representation
A concise decorator for retrieving an IP address from http request with Nest.js controller method.
- Host: GitHub
- URL: https://github.com/p0vidl0/nestjs-real-ip
- Owner: p0vidl0
- License: mit
- Created: 2020-11-05T02:15:06.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-19T03:46:04.000Z (over 1 year ago)
- Last Synced: 2024-10-13T08:05:39.053Z (3 months ago)
- Topics: ip, ip-address, nest, nestjs, real-ip, typescript
- Language: TypeScript
- Homepage:
- Size: 693 KB
- Stars: 46
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nest.js real ip decorator
A concise decorator for retrieving an IP address from http request with Nest.js controller method.
[![NPM package link](https://nodei.co/npm/nestjs-real-ip.png?downloads=true&cacheBust=2)](https://www.npmjs.com/package/nestjs-real-ip)
## Installation
```shell script
# Install the upstream version for projects based on NestJS v8 and above
npm install nestjs-real-ip# Or use the version 1.0.3 for projects based on NestJS v7
npm install [email protected]
```## Example controller
```typescript
import { RealIP } from 'nestjs-real-ip';@Controller('/')
class TestController {
@Get('my-ip')
get(@RealIP() ip: string): string {
return ip;
}
}
```## Under the hood
Based on the tiny module [@supercharge/request-ip](https://github.com/supercharge/request-ip).
It supports a wide list of request headers and properties to get working in almost any environment.
See the request-ip module description for details.Also, see the decorator's [tests](__tests__/index.spec.ts).
## License
The code is under MIT license. See the LICENSE file for details.## Development
```shell script
# Update code, commit and push with git
npm version [ major | minor | patch ]
npm publish
```