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

Commit

Permalink
Update readme and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sktt committed Aug 17, 2016
1 parent 6127699 commit 8bd9d3c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
Access Watch Node library
Access Watch Node library [![Build Status](https://travis-ci.org/access-watch/access-watch-node.svg?branch=master)](https://travis-ci.org/access-watch/access-watch-node) [![Coverage Status](https://coveralls.io/repos/github/access-watch/access-watch-node/badge.svg?branch=master)](https://coveralls.io/github/access-watch/access-watch-node?branch=master)
-------------------------
[![Build Status](https://travis-ci.org/access-watch/access-watch-node.svg?branch=master)](https://travis-ci.org/access-watch/access-watch-node)
[![Coverage Status](https://coveralls.io/repos/github/access-watch/access-watch-node/badge.svg?branch=master)](https://coveralls.io/github/access-watch/access-watch-node?branch=master)

A nodejs implementation for logging and analysing web traffic using the
AccessWatch service. This library provides the utilities for communication with
the AccessWatch service.

### Usage ###
In case there is no implementation for your configuration you can build your own
using this library directly. For Express and Hapi plugins check out
[access-watch-middleware](https://github.com/access-watch/access-watch-middleware) and
[access-watch-hapi](https://github.com/access-watch/access-watch-hapij)
respectively.

*If you are using Express or Hapi, you might want to use their
respective implementations which are based on this.* In case there is no
implementation for your configuration you can build your own using this library
directly.
## Usage ##

If the node application is behind a reverse proxy, to correctly log the request,
extra headers should be set and specified for the instance.
Typically the predefined `AccessWatch.proxyHeaders` can be used. It expects the
headers `X-Forwarded-For`, `X-Forwarded-Proto` and `X-Forwarded-Host` to be set.
```
npm install --save access-watch
```

For example code, see the referenced plugins mentioned above.

If the node application is behind a reverse proxy, it should set forwarded headers which
must specified to AccessWatch on instantiation. Typically the predefined
[`AccessWatch.fwdHeaders`](./api.md#AccessWatch.fwdHeaders) can be used.

See [API documentation](./api.md) for details.

### Contributing ###
## Contributing ##

- Before doing any work, always open an issue.
- Before commiting any code, always make sure `npm test` and `npm run lint`
Expand Down
14 changes: 7 additions & 7 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Handles logging, caching and checking for blocked requets.
* [.lookupSession(req, noCache)](#AccessWatch+lookupSession) ⇒ <code>Promise</code>
* [.checkBlocked(req)](#AccessWatch+checkBlocked) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.log(req, res)](#AccessWatch+log) ⇒ <code>Promise</code>
* [.requestIdentity(req)](#AccessWatch+requestIdentity) ⇒ <code>string</code>
* [.requestSignature(req)](#AccessWatch+requestSignature) ⇒ <code>string</code>
* _static_
* [.Cache](#AccessWatch.Cache)
* [.get(id, callback)](#AccessWatch.Cache+get)
Expand All @@ -36,8 +36,8 @@ Handles logging, caching and checking for blocked requets.
<a name="AccessWatch+hello"></a>

### accessWatch.hello() ⇒ <code>Promise</code>
Make sure the apiBase and apiKey are correctly set up. Probably done every
time a server launches
Make sure the `apiBase` and `apiKey` are correctly set up. Probably done
every time a server launches

**Kind**: instance method of <code>[AccessWatch](#AccessWatch)</code>
**Returns**: <code>Promise</code> - Rejects unless a 200 is returned from the api
Expand All @@ -56,8 +56,8 @@ Look up a Session from cache or api with a node request
<a name="AccessWatch+checkBlocked"></a>

### accessWatch.checkBlocked(req) ⇒ <code>Promise.&lt;boolean&gt;</code>
Check if a request should be blocked by checking for the requestIdentity in
the cache.
Check if a request should be blocked by checking for the requestSignature
in the cache.
NOTE: If its a cache miss, default will be `false` since we should never
add extra latency to the response times or making it dependent on the
access watch api service.
Expand All @@ -80,9 +80,9 @@ Send request and response data to AccessWatch API.
| req | <code>http.IncomingMessage</code> | A raw node request |
| res | <code>http.ServerResponse</code> | A raw node response |

<a name="AccessWatch+requestIdentity"></a>
<a name="AccessWatch+requestSignature"></a>

### accessWatch.requestIdentity(req) ⇒ <code>string</code>
### accessWatch.requestSignature(req) ⇒ <code>string</code>
An identifier hash to associate a certain type of requests with a Session.
Simply a combination of the address and some headers.

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class AccessWatch {
}

/**
* Make sure the apiBase and apiKey are correctly set up. Probably done every
* time a server launches
* Make sure the `apiBase` and `apiKey` are correctly set up. Probably done
* every time a server launches
* @return {Promise} Rejects unless a 200 is returned from the api
*/
hello() {
Expand Down

0 comments on commit 8bd9d3c

Please sign in to comment.