Skip to content

Commit

Permalink
fix: Use appId and apiKey keys
Browse files Browse the repository at this point in the history
This was previously `applicationID` and `searchAPIKey` which was too
long and confusing.
  • Loading branch information
pixelastic committed Sep 14, 2015
1 parent d8b6372 commit 5716552
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ API is unstable. We welcome any idea.

```js
var instantsearch = require('instantsearch.js');
var search = instantsearch(appId, apiKey, indexName);
var search = instantsearch({
appId: appId,
apiKey: apiKey,
indexName: indexName
});

// add a widget
search.addWidget(
Expand Down
4 changes: 2 additions & 2 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ require('./style.css');
var instantsearch = require('../');

var search = instantsearch({
applicationID: 'latency',
searchAPIKey: '6be0576ff61c053d5f9a3225e2a90f76',
appId: 'latency',
apiKey: '6be0576ff61c053d5f9a3225e2a90f76',
indexName: 'instant_search'
});

Expand Down
16 changes: 8 additions & 8 deletions lib/InstantSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ var union = require('lodash/array/union');

class InstantSearch {
constructor({
applicationID = null,
searchAPIKey = null,
appId = null,
apiKey = null,
indexName = null,
defaultSearchParameters = {}
searchParameters = {}
}) {
if (applicationID === null || searchAPIKey === null || indexName === null) {
if (appId === null || apiKey === null || indexName === null) {
var usage = `
Usage: instantsearch({
applicationID: 'my_application_id',
searchAPIKey: 'my_search_api_key',
appId: 'my_application_id',
apiKey: 'my_search_api_key',
indexName: 'my_index_name'
});`;
throw new Error(usage);
}


var client = algoliasearch(applicationID, searchAPIKey);
var client = algoliasearch(appId, apiKey);

this.client = client;
this.helper = null;
this.indexName = indexName;
this.searchParameters = defaultSearchParameters || {};
this.searchParameters = searchParameters || {};
this.widgets = [];
}

Expand Down
6 changes: 3 additions & 3 deletions test/InstantSearch/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ test('InstantSearch: lifecycle', function(t) {
});

var search = new InstantSearch({
applicationID: appId,
searchAPIKey: apiKey,
appId: appId,
apiKey: apiKey,
indexName: indexName,
defaultSearchParameters: searchParameters
searchParameters: searchParameters
});

// instantiates a client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ test('InstantSearch: recursively merge arrays in searchParameters', function(t)
});

var search = new InstantSearch({
applicationID: 'appId',
searchAPIKey: 'apiKey',
appId: 'appId',
apiKey: 'apiKey',
indexName: 'recursively',
defaultSearchParameters: searchParameters
searchParameters: searchParameters
});

search.addWidget(firstWidget);
Expand Down

0 comments on commit 5716552

Please sign in to comment.