Skip to content

Commit

Permalink
Bump got@11.8.2 (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Aug 2, 2021
1 parent 1502993 commit 56aed04
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ jobs:
fail-fast: false
matrix:
node-version:
# Uncomment when using Got v10
# - 14
# - 12
- 14
- 12
- 10
- 8
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ alfy.cache = new CacheConf({

alfy.fetch = async (url, options) => {
options = {
json: true,
...options
};

Expand All @@ -132,7 +131,7 @@ alfy.fetch = async (url, options) => {

let response;
try {
response = await got(url, options);
response = await got(url, {searchParams: options.query}).json();
} catch (error) {
if (cachedResponse) {
return cachedResponse;
Expand All @@ -141,7 +140,7 @@ alfy.fetch = async (url, options) => {
throw error;
}

const data = options.transform ? options.transform(response.body) : response.body;
const data = options.transform ? options.transform(response) : response;

if (options.maxAge) {
alfy.cache.set(key, data, {maxAge: options.maxAge});
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"alfy-cleanup": "cleanup.js"
},
"engines": {
"node": ">=8"
"node": ">=10"
},
"scripts": {
"test": "xo && ava"
Expand Down Expand Up @@ -43,7 +43,7 @@
"dot-prop": "^5.1.0",
"esm": "^3.2.18",
"execa": "^2.0.4",
"got": "^9.3.2",
"got": "^11.8.2",
"hook-std": "^2.0.0",
"loud-rejection": "^2.1.0",
"read-pkg-up": "^6.0.0"
Expand Down
6 changes: 3 additions & 3 deletions test/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('cache key', async t => {
const alfy = createAlfy();

t.deepEqual(await alfy.fetch(`${URL}/cache-key`, {query: {unicorn: 'rainbow'}, maxAge: 5000}), {unicorn: 'rainbow'});
t.truthy(alfy.cache.store['https://foo.bar/cache-key{"json":true,"query":{"unicorn":"rainbow"},"maxAge":5000}']);
t.truthy(alfy.cache.store['https://foo.bar/cache-key{"query":{"unicorn":"rainbow"},"maxAge":5000}']);
});

test('invalid version', async t => {
Expand All @@ -65,12 +65,12 @@ test('invalid version', async t => {
const alfy = createAlfy({cache, version: '1.0.0'});
t.deepEqual(await alfy.fetch(`${URL}/cache-version`, {maxAge: 5000}), {foo: 'bar'});
t.deepEqual(await alfy.fetch(`${URL}/cache-version`, {maxAge: 5000}), {foo: 'bar'});
t.deepEqual(alfy.cache.store['https://foo.bar/cache-version{"json":true,"maxAge":5000}'].data, {foo: 'bar'});
t.deepEqual(alfy.cache.store['https://foo.bar/cache-version{"maxAge":5000}'].data, {foo: 'bar'});

const alfy2 = createAlfy({cache, version: '1.0.0'});
t.deepEqual(await alfy2.fetch(`${URL}/cache-version`, {maxAge: 5000}), {foo: 'bar'});

const alfy3 = createAlfy({cache, version: '1.0.1'});
t.deepEqual(await alfy3.fetch(`${URL}/cache-version`, {maxAge: 5000}), {unicorn: 'rainbow'});
t.deepEqual(alfy.cache.store['https://foo.bar/cache-version{"json":true,"maxAge":5000}'].data, {unicorn: 'rainbow'});
t.deepEqual(alfy.cache.store['https://foo.bar/cache-version{"maxAge":5000}'].data, {unicorn: 'rainbow'});
});

0 comments on commit 56aed04

Please sign in to comment.