Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/microlinkhq/ua

A simple redis primitives to incr() and top() user agents
https://github.com/microlinkhq/ua

crawler redis user-agent user-agent-parser

Last synced: 4 days ago
JSON representation

A simple redis primitives to incr() and top() user agents

Awesome Lists containing this project

README

        


microlink logo
microlink logo




![Last version](https://img.shields.io/github/tag/microlinkhq/ua.svg?style=flat-square)
[![Coverage Status](https://img.shields.io/coveralls/microlinkhq/ua.svg?style=flat-square)](https://coveralls.io/github/microlinkhq/ua)
[![NPM Status](https://img.shields.io/npm/dm/microlinkhq/ua.svg?style=flat-square)](https://www.npmjs.org/package/microlinkhq/ua)

> A simple redis primitives to incr() and top() user agents.

## Install

```sh
npm install @microlink/ua
```

## Usage

First, initialize the library passing a Redis instance:

```js
const Redis = require('ioredis')
const redis = new Redis()
const ua = require('@microlink/ua')(redis)
```

After that, the library offers the following methods:

- **incr(userAgent)** — e.g. `ua.incr(req.headers['user-agent'])`

Increment the counter associated with an user agent.

- **top(n, { withScore })** — e.g. `ua.top(100)`

Returns an array of the N ranked from from top.

- **flush** — e.g. `ua.delete()`

Delete elements.

## License

**microlink/ua** © [microlink.io](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/ua/blob/master/LICENSE.md) License.

Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/microlinkhq/queue/contributors).

> [microlink.io](https://microlink.io) · GitHub [microlink.io](https://github.com/microlinkhq) · X [@microlinkhq](https://x.com/microlinkhq)