Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stouderio/adonis-geolite2
Maxmind's GeoLite2 integration for Adonis
https://github.com/stouderio/adonis-geolite2
adonis adonisjs geolite geolite2 geolite2-asn geolite2-city geolite2-country maxmind
Last synced: 6 days ago
JSON representation
Maxmind's GeoLite2 integration for Adonis
- Host: GitHub
- URL: https://github.com/stouderio/adonis-geolite2
- Owner: StouderIO
- License: mit
- Created: 2023-01-16T00:24:38.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-09T12:31:10.000Z (6 months ago)
- Last Synced: 2024-05-09T22:41:13.500Z (6 months ago)
- Topics: adonis, adonisjs, geolite, geolite2, geolite2-asn, geolite2-city, geolite2-country, maxmind
- Language: TypeScript
- Homepage:
- Size: 289 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Legal Warning
This package uses [geolite2-redist](https://www.npmjs.com/package/geolite2-redist) and thus, you MUST comply with it specifics conditions. For more informations please check their [npm page](https://www.npmjs.com/package/geolite2-redist#user-content-legal-warning).## Installation
```
node ace add @stouder-io/adonis-geolite2
```Alternatively, you can install it manually.
```
npm i @stouder-io/adonis-geolite2
```If installed manually, you need to manually run the configuration command.
```
node ace configure @stouder-io/adonis-geolite2
```## Usage
The geolite2 is automatically attached to HTTP requests, allowing you to use it to retries informations about the geolocation of requesting IPs.
```ts
router.get('/', ({ geolite2 }: HttpContext) => {
const country = geolite2.country()
const city = geolite2.city()
const asn = geolite2.asn()return { country, city, asn }
})
```If no parameter is provided to the functions, it uses [`request.ip()`](https://docs.adonisjs.com/guides/request#request-ip-address). Alternatively you can pass the IP you want to lookup.
```ts
router.get('/', ({ geolite2 }: HttpContext) => {
const country = geolite2.country('8.8.8.8')
const city = geolite2.city('8.8.8.8')
const asn = geolite2.asn('8.8.8.8')return { country, city, asn }
})
```