# @voodoo.io/maxmind-reader

> Simple module to read a maxmind db from S3 a keep it into memory! You can also retrieve the file periodically.

Latest version **1.0.12** (published 2022-12-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @voodoo.io/maxmind-reader
pnpm add @voodoo.io/maxmind-reader
yarn add @voodoo.io/maxmind-reader
bun add @voodoo.io/maxmind-reader
```

Provides the command `maxmind-reader`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2022-12-27 |
| First published | 2019-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Vincent Vallet |
| Maintainers | voodooio, vincentvallet_voodoo, clintvoodoo, clementc, raphaelyazdi |
| Keywords | retry, maxmind, geoloc |

## Links

- npm: https://www.npmjs.com/package/@voodoo.io/maxmind-reader
- Repository: https://github.com/VoodooTeam/maxmind-reader
- Issues: https://github.com/VoodooTeam/maxmind-reader/issues
- npm.io page: https://npm.io/package/@voodoo.io/maxmind-reader

## Dependencies (2)

- [maxmind](https://npm.io/package/maxmind.md) 4.3.8
- [async-await-retry](https://npm.io/package/async-await-retry.md) 2.0.1

## Recent versions

- 1.0.12 (latest) — 2022-12-27
- 1.0.11 — 2022-06-30
- 1.0.10 — 2021-11-17
- 1.0.8 — 2021-07-22
- 1.0.7 — 2021-06-02
- 1.0.6 — 2021-01-06
- 1.0.5 — 2021-01-06
- 1.0.4 — 2020-07-28
- 1.0.3 — 2020-04-21
- 1.0.2 — 2019-12-30
- 1.0.1 — 2019-08-30
- 1.0.0 — 2019-08-13

## README

<div align="center">
<b>Maxmind reader</b><br/>
<br/><br/>
</div>

[![npm version](https://badge.fury.io/js/%40voodoo.io%2Fmaxmind-reader.svg)](https://badge.fury.io/js/%40voodoo.io%2Fmaxmind-reader)
[![GitHub license](https://img.shields.io/github/license/VoodooTeam/maxmind-reader)](https://github.com/VoodooTeam/maxmind-reader/blob/master/LICENSE)
[![CI pipeline](https://github.com/VoodooTeam/maxmind-reader/workflows/Node.js%20CI/badge.svg)](https://github.com/VoodooTeam/maxmind-reader/actions?query=workflow%3A%22Node.js+CI%22)
[![Opened issues](https://img.shields.io/github/issues-raw/VoodooTeam/maxmind-reader)](https://github.com/VoodooTeam/maxmind-reader/issues)
[![Opened PR](https://img.shields.io/github/issues-pr-raw/VoodooTeam/maxmind-reader)](https://github.com/VoodooTeam/maxmind-reader/pulls)
[![DeepScan grade](https://deepscan.io/api/teams/12068/projects/15411/branches/307224/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=12068&pid=15411&bid=307224)
[![Code coverage](https://codecov.io/gh/VoodooTeam/maxmind-reader/branch/master/graph/badge.svg)](https://codecov.io/gh/VoodooTeam/maxmind-reader)
![Dependencies](https://img.shields.io/david/VoodooTeam/maxmind-reader)


# Purpose

Minimalist, efficient and performance focused module to read a maxmind database.
Basically it can read a maxmind db from S3 and store it into memory.

# Compatibility

**/!\ This module use async/await syntax, this is why you must have node 7.6+.**

Supported and tested : >= 14

| Version       | Supported     | Tested         |
| ------------- |:-------------:|:--------------:|
| 18.x          | yes           | yes            |
| 16.x          | yes           | yes            |
| 14.x          | yes           | yes            |
| 12.x          | no            | yes            |
| 10.x          | no            | yes            |
| 9.x           | no            | yes            |
| 8.x           | no            | yes            |
| >= 7.6        | no            | yes            |

# Installation

```console
$ npm install @voodoo.io/maxmind-reader --save
```

# Usage

## Instantiation & init

```javascript
const S3Tools = require('@voodoo.io/aws-utils').s3
const s3 = new aws.S3()
const s3Tools = new S3Tools(s3)

const Geoloc = require('@voodoo.io/maxmind-reader')
const geoloc = new Geoloc({
  // here is your config
}, s3Tools)

// launch the interval to reload the file
// the delay can be customized as parameter
await geoloc.init()
```

## Basic usage
```javascript
const isoCode = geoloc.getCountry('149.62.156.82')
// isoCode equals 'FR'
```

## Config

| Property           | description                              | Default value  |
| -------------------|:----------------------------------------:|:--------------:|
| `S3_GEOLOC_KEY`    | '/path/to/GeoLite2-Country.mmdb'         | empty          |
| `S3_GEOLOC_BUCKET` | Bucket's name                            | empty          |
| `delay`            | Interval in ms between two reloading     | 3600000 (1hour)|
| `enableScheduler`  | Enable the scheduler?                    | true           |

# Test

```console
$ npm test
```

Coverage report can be found in coverage/.

---
_Source: https://npm.io/package/@voodoo.io/maxmind-reader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
