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

Commit 2e2b3af

Browse files
committed
refactoring(Apisearch): remove http cache option
1 parent 1c31bfb commit 2e2b3af

File tree

9 files changed

+53
-51
lines changed

9 files changed

+53
-51
lines changed

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ const api = apisearch({
9898
apiVersion: ?string, // (default "v1")
9999
timeout: ?integer, // in seconds (default 1000)
100100
overrideQueries: ?bool, // (default true)
101-
cache: {
102-
inMemory: ?bool, // (default true)
103-
http: ?integer // in seconds (default 0)
104-
}
101+
cache: ?bool // in memory cache (default true)
105102
}
106103
});
107104
```
@@ -226,7 +223,7 @@ universe by types A and B. Let's see how to do it.
226223
```javascript
227224
let query = api.query
228225
.createMatchAll()
229-
filterUniverseByTypes(['A', 'B']);
226+
.filterUniverseByTypes(['A', 'B']);
230227
```
231228
232229
All possible results will only include A and B. Think about this filter as
@@ -323,7 +320,7 @@ maximum 3 items.
323320
```javascript
324321
let query = api.query
325322
.createMatchAll()
326-
filterByIds(['10', '11', '12']);
323+
.filterByIds(['10', '11', '12']);
327324
```
328325
329326
## Filter by location
@@ -363,8 +360,8 @@ let to = (new Date('01 October 2017 20:00 UTC')).toISOString();
363360

364361
let query = api.query
365362
.createMatchAll()
366-
filterUniverseByRange('price', ['0..20'], 'FILTER_MUST_ALL')
367-
filterUniverseByDateRange('created_at', [`${from}..${to}`], 'FILTER_MUST_ALL');
363+
.filterUniverseByRange('price', ['0..20'], 'FILTER_MUST_ALL')
364+
.filterUniverseByDateRange('created_at', [`${from}..${to}`], 'FILTER_MUST_ALL');
368365
```
369366
370367
Furthermore, once defined your subset of available values, you can
@@ -382,7 +379,7 @@ filter.
382379
```javascript
383380
let query = api.query
384381
.createMatchAll()
385-
filterByRange(
382+
.filterByRange(
386383
'price',
387384
'price',
388385
[],
@@ -513,8 +510,10 @@ on your browser:
513510
514511
# Developer resources:
515512
516-
* `npm run dev`: will start a watcher on `./src/**/*`, bundle at every code
513+
* `npm run dev` or `yarn dev`: will start a watcher on `./src/**/*`, bundle at every code
517514
change and export it on `./dist/apisearch.js`.
518-
* `npm run build`: will bundle and minify all code and export it on
515+
* `npm run build` or `yarn build`: will bundle and minify all code and export it on
519516
`./dist/apisearch.min.js`.
520-
* `npm run test` or `npm t`: will run the test suite using Mocha and Chai.
517+
* `npm run dist` or `yarn dist`: cleans the `dist` directory and bundles the dev
518+
and build version. Ready for release.
519+
* `npm t` or `yarn test`: will run the test suite using Mocha and Chai.

dist/apisearch.js

Lines changed: 14 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.node.js

Lines changed: 14 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.node.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.node.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Apisearch.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ class Apisearch {
1818
apiVersion,
1919
timeout,
2020
overrideQueries,
21-
cache: {
22-
inMemory: inMemoryCache,
23-
http: httpCacheTTL
24-
}
21+
cache: inMemoryCache
2522
}
2623
}) {
2724
/**
@@ -31,7 +28,6 @@ class Apisearch {
3128
this.apiKey = apiKey;
3229
this.apiVersion = apiVersion;
3330
this.endpoint = endpoint;
34-
this.httpCacheTTL = httpCacheTTL;
3531
this.timeout = timeout;
3632
this.overrideQueries = overrideQueries;
3733

@@ -49,6 +45,13 @@ class Apisearch {
4945
);
5046
}
5147

48+
/**
49+
* Search entry point
50+
*
51+
* @param query
52+
* @param callback
53+
* @returns {Promise}
54+
*/
5255
search(query, callback) {
5356
let encodedQuery = encodeURIComponent(
5457
JSON.stringify(query)

src/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@ module.exports = function({
1919
checkApiKey(apiKey);
2020

2121
options = {
22-
endpoint: '//puntmig.net',
22+
endpoint: '//api.apisear.ch',
2323
apiVersion: 'v1',
2424
timeout: 10000,
2525
overrideQueries: true,
26+
cache: true,
2627
...options,
27-
cache: {
28-
inMemory: true,
29-
http: 0,
30-
...options.cache
31-
},
3228
};
3329

3430
return new Apisearch({

0 commit comments

Comments
 (0)