Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Added README and tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettRToomey committed Jan 27, 2017
1 parent 0bea269 commit 133ac76
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage:
range: "0...100"
ignore:
- "Tests/"
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
os:
- linux
- osx
language: generic
sudo: required
dist: trusty
osx_image: xcode8
script:
- eval "$(curl -sL https://swift.vapor.sh/ci)"
- eval "$(curl -sL https://swift.vapor.sh/codecov)"
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# GateKeeper
[![Language](https://img.shields.io/badge/Swift-3-brightgreen.svg)](http://swift.org)
[![Build Status](https://travis-ci.org/nodes-vapor/gatekeeper.svg?branch=master)](https://travis-ci.org/nodes-vapor/gatekeeper)
[![codecov](https://codecov.io/gh/nodes-vapor/gatekeeper/branch/master/graph/badge.svg)](https://codecov.io/gh/nodes-vapor/gatekeeper)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nodes-vapor/gatekeeper/master/LICENSE)

Rate Limiter and SSL enforcing middleware.

## Integration
Update your `Package.swift` file.
```swift
.Package(url: "https://github.com/nodes-vapor/paginator", majorVersion: 0)
```

## Getting started ๐Ÿš€
Both the rate limiter and SSL-enforcing middleware are easy to configure and get running.

## SSLEnforcer ๐Ÿ”’
`SSLEnforcer` has three configurable fields: the error to be thrown, your `Droplet` and the environments you wish to enforce on. The environments defaults to `[.production]`.
```swift
let drop = Droplet()
// this will only enforce if running in `production` mode.
let enforcer = SSLEnforcer(error: Abort.notFound, drop: drop)
```

If you wish to secure your endpoints during development you can do the following:
```swift
let enforcer = SSLEnforcer(
error: Abort.notFound,
drop: drop,
environments: [
.production,
.development
]
)
```

## RateLimiter โฑ
`RateLimiter` has two configurable fields: the maximum rate and the cache to use. If you don't supply your own cache the limiter will create its own, in-memory cache.

```swift
let limiter = RateLimiter(rate: Rate(10, per: .minute))
```

### The `Rate.Interval` enumeration
The currently implemented intervals are:
```swift
case .second
case .minute
case .hour
case .day
```

## Credits ๐Ÿ†
This package is developed and maintained by the Vapor team at [Nodes](https://www.nodes.dk).

## License ๐Ÿ“„
This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

0 comments on commit 133ac76

Please sign in to comment.