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

Commit

Permalink
Merge pull request #2 from AubreyHewes/master
Browse files Browse the repository at this point in the history
Add host header override (ie for use when tunnelling etc a la php connector)
  • Loading branch information
Reggino committed Dec 24, 2015
2 parents e5f30c7 + 0697384 commit 289247b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ If you need to connect to a specific version of the endpoint, you may want to se
COMMUNIBASE_API_URL=https://api.communibase.nl/0.1/
```

### Use via a tunnel requires also adding an extra Host header

```bash
COMMUNIBASE_API_URL=https://17.42.0.1:8888/0.1/ COMMUNIBASE_API_HOST=api.communibase.nl node script.js
```

API
---

Expand Down Expand Up @@ -127,17 +133,17 @@ Alternatively, you can search the entire history of documents to look for specif
```js
//Lookup all versions of any person (even deleted documents) ever with first name Tim.

cbc.historySearch('Person', { firstName: 'Tim' }): Promise for VersionInformation[]
cbc.historySearch('Person', { firstName: 'Tim' }): Promise for VersionInformation[]
```

VersionInformation has the following structure
* _id - The _id of the version.
* refId - The _id of the original document. You can use this at the regular CRUD endpoint
* updatedAt - The date this version was created
* updatedBy - A human readable description describing who created it

With an _id and a refId, we can lookup that specific version via the API

```js
cbc.getById(entityType, id, params, versionId) : Promise for version of document;
```
Expand Down Expand Up @@ -186,4 +192,4 @@ The connector may cache documents locally. To enable in-memory cache for a certa
cbc.enableCache(communibaseAdministrationId, socketServiceUrl)
```

Contact Kingsquare for these values in your particular scenario and use with caution: BEWARE of excessive memory usage!
Contact Kingsquare for these values in your particular scenario and use with caution: BEWARE of excessive memory usage!
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ var Connector = function (key) {
if (!task.options.headers) {
task.options.headers = {};
}
if (process.env.COMMUNIBASE_API_HOST) {
task.options.headers['Host'] = process.env.COMMUNIBASE_API_HOST;
}
task.options.headers['x-api-key'] = self.key;
restler[task.method](task.url, task.options).on('success', success).on('fail', fail).on('error', fail);
}, 8);
Expand Down

0 comments on commit 289247b

Please sign in to comment.