Skip to content

Commit

Permalink
docs(readme): update readme, using verb
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Oct 7, 2016
1 parent 14e1bd7 commit 4622cd2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 34 deletions.
70 changes: 38 additions & 32 deletions README.md
@@ -1,17 +1,15 @@
# koa-ip-filter [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url]
# [koa-ip-filter][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url]

> [koa](https://github.com/koajs/koa) middleware to filter request IPs or custom ID with glob patterns, array, string, regexp or matcher function. Support custom `403 Forbidden` message and custom ID.
> Middleware for [koa][] that filters IPs against glob patterns, RegExp, string or array of globs. Support custom `403 Forbidden` message and custom ID.
[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]


## Install

```
npm i koa-ip-filter --save
npm test
```


## Features
- custom message when `403 Forbidden` response, through `opts.forbidden`
- custom identifier different than default `this.ip`, through `opts.id`
Expand All @@ -20,25 +18,30 @@ npm test
- blacklist with negative glob patterns, whitelist with positive
- would restrict all to `403 Forbidden` that not match to filter


> **Notice:** In the next middleware you will have `this.filter` method which is [ip-filter](https://github.com/tunnckoCore/ip-filter)
> **Notice:** In the next middleware you will have `this.filter` method which is [ip-filter][]
> and `this.identifier` - the IP/ID that passed the given filter

## Usage
> For more use-cases see the [tests](./test.js)
### [koaIpFilter](./index.js#L26)
```js
const koaIpFilter = require('koa-ip-filter')
```

### [koaIpFilter](index.js#L51)
> Filtering incoming request with glob patterns array, regexp, string or matcher function
- `options` **{Object}**
+ `id` **{Function}** custom identifier, defaults to `this.ip`
+ `strict` **{Boolean}** to throw when not valid IPv4/IPv6? default `true`
+ `filter` **{Array|String|RegExp|Function}** filter
+ `forbidden` **{String|Function}** custom message when `403 Forbidden` response
- `returns` **{GeneratorFunction}**
**Params**

* `options` **{Object}**
- `id` **{Function}**: custom identifier, defaults to `this.ip`
- `strict` **{Boolean}**: to throw when not valid IPv4/IPv6? default `true`
- `filter` **{Array|String|RegExp|Function}**: black/white list filter
- `forbidden` **{String|Function}**: custom message when `403 Forbidden` response
* `returns` **{GeneratorFunction}**

**Example**

```js
'use strict'

Expand Down Expand Up @@ -88,38 +91,41 @@ console.log('koa server start listening on http://localhost:1234')
// will see the message `403: Get out of here!`
```


## Related
- [express-ip-filter](https://github.com/tunnckocore/express-ip-filter): Express middleware to filter IPs with glob patterns, string, array or function, with blacklist and whitelist options, plus custom identifier
- [express-better-ratelimit](https://github.com/tunnckoCore/express-better-ratelimit): Express.js request rate limit middleware by IP with MemoryStore
- [ip-filter](https://github.com/tunnckocore/ip-filter): Filter valid IPv4 or IPv6 IP against glob pattern, array, string, regexp or matcher function, if match return the checked IP, otherwise return falsey value.
- [koa-better-ratelimit](https://github.com/tunnckoCore/koa-better-ratelimit): Better, smaller, faster - koa middleware for limit request by ip, store in-memory.
- [koa-better-body](https://github.com/tunnckoCore/koa-better-body): A koa body parser middleware with support for `multipart`, `json`, `csp-report` or `urlencoded` request bodies. Via formidable and co-body.

- [ip-filter](https://www.npmjs.com/package/ip-filter): Filters valid IPv4 or IPv6 against glob pattern, array, string and etc… [more](https://github.com/tunnckocore/ip-filter#readme) | [homepage](https://github.com/tunnckocore/ip-filter#readme "Filters valid IPv4 or IPv6 against glob pattern, array, string and etc. If match returns passed `ip`, otherwise null is returned. Have no strict mode to check no IP values.")
- [is-match-ip](https://www.npmjs.com/package/is-match-ip): Matching IPs using [micromatch][] and [ip-filter][] - glob patterns, RegExp, string or… [more](https://github.com/tunnckocore/is-match-ip#readme) | [homepage](https://github.com/tunnckocore/is-match-ip#readme "Matching IPs using [micromatch][] and [ip-filter][] - glob patterns, RegExp, string or array of globs. Returns matcher function.")
- [is-match](https://www.npmjs.com/package/is-match): Create a matching function from a glob pattern, regex, string, array, object… [more](https://github.com/jonschlinkert/is-match) | [homepage](https://github.com/jonschlinkert/is-match "Create a matching function from a glob pattern, regex, string, array, object or function.")
- [koa-better-body](https://www.npmjs.com/package/koa-better-body): Full-featured [koa][] body parser! Support parsing text, buffer, json, json patch, json… [more](https://github.com/tunnckocore/koa-better-body#readme) | [homepage](https://github.com/tunnckocore/koa-better-body#readme "Full-featured [koa][] body parser! Support parsing text, buffer, json, json patch, json api, csp-report, multipart, form and urlencoded bodies. Works for koa@1, koa@2 and will work for koa@3.")
- [koa-ip-filter](https://www.npmjs.com/package/koa-ip-filter): koa middleware to filter request IPs or custom ID with glob patterns… [more](https://github.com/tunnckocore/koa-ip-filter#readme) | [homepage](https://github.com/tunnckocore/koa-ip-filter#readme "koa middleware to filter request IPs or custom ID with glob patterns, array, string, regexp or matcher function. Support custom `403 Forbidden` message and custom ID.")
- [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch… [more](https://github.com/jonschlinkert/micromatch) | [homepage](https://github.com/jonschlinkert/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/koa-ip-filter/issues/new).
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/koa-ip-filter/issues/new).
But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.


## [Charlike Make Reagent](http://j.mp/1stW47C) [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]

[![tunnckocore.tk][author-www-img]][author-www-url] [![keybase tunnckocore][keybase-img]][keybase-url] [![tunnckoCore npm][author-npm-img]][author-npm-url] [![tunnckoCore twitter][author-twitter-img]][author-twitter-url] [![tunnckoCore github][author-github-img]][author-github-url]
[![tunnckoCore.tk][author-www-img]][author-www-url] [![keybase tunnckoCore][keybase-img]][keybase-url] [![tunnckoCore npm][author-npm-img]][author-npm-url] [![tunnckoCore twitter][author-twitter-img]][author-twitter-url] [![tunnckoCore github][author-github-img]][author-github-url]

[ip-filter]: https://github.com/tunnckocore/ip-filter
[is-match]: https://github.com/jonschlinkert/is-match
[koa]: https://github.com/koajs/koa
[micromatch]: https://github.com/jonschlinkert/micromatch

[npmjs-url]: https://www.npmjs.com/package/koa-ip-filter
[npmjs-img]: https://img.shields.io/npm/v/koa-ip-filter.svg?label=koa-ip-filter

[license-url]: https://github.com/tunnckoCore/koa-ip-filter/blob/master/LICENSE.md
[license-img]: https://img.shields.io/badge/license-MIT-blue.svg
[license-url]: https://github.com/tunnckoCore/koa-ip-filter/blob/master/LICENSE
[license-img]: https://img.shields.io/npm/l/koa-ip-filter.svg

[downloads-url]: https://www.npmjs.com/package/koa-ip-filter
[downloads-img]: https://img.shields.io/npm/dm/koa-ip-filter.svg

[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/koa-ip-filter
[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/koa-ip-filter.svg

[travis-url]: https://travis-ci.org/tunnckoCore/koa-ip-filter
[travis-img]: https://img.shields.io/travis/tunnckoCore/koa-ip-filter.svg
[travis-img]: https://img.shields.io/travis/tunnckoCore/koa-ip-filter/master.svg

[coveralls-url]: https://coveralls.io/r/tunnckoCore/koa-ip-filter
[coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/koa-ip-filter.svg
Expand All @@ -130,7 +136,6 @@ But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md)
[standard-url]: https://github.com/feross/standard
[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg


[author-www-url]: http://www.tunnckocore.tk
[author-www-img]: https://img.shields.io/badge/www-tunnckocore.tk-fe7d37.svg

Expand All @@ -149,5 +154,6 @@ But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md)
[freenode-url]: http://webchat.freenode.net/?channels=charlike
[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg

[new-message-url]: https://github.com/tunnckoCore/messages
[new-message-img]: https://img.shields.io/badge/send%20me-message-green.svg
[new-message-url]: https://github.com/tunnckoCore/ama
[new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg

5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -82,7 +82,8 @@
"ip-filter",
"koa-ip-filter",
"koa-better-body",
"micromatch"
"micromatch",
"is-match-ip"
]
},
"reflinks": [
Expand All @@ -95,4 +96,4 @@
"reflinks": true
}
}
}
}

0 comments on commit 4622cd2

Please sign in to comment.