-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Marcin Rataj <lidel@lidel.org> BREAKING CHANGE: minified version is ESM now
- Loading branch information
Showing
13 changed files
with
166 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export default { | ||
tsRepo: false, | ||
build: { | ||
config: { | ||
format: 'esm', | ||
banner: { | ||
js: '' | ||
}, | ||
footer: { | ||
js: '' | ||
} | ||
} | ||
}, | ||
test: { | ||
before: (...args) => { | ||
if (args[0].runner === 'node') { | ||
return { | ||
env: { | ||
NODE_OPTIONS: '--loader=esmock' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root=true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const MAX_LOOKUP_RETRIES = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { decode as dagCborDecode } from '@ipld/dag-cbor' | ||
import esmock from 'esmock' | ||
import { expect } from 'chai' | ||
|
||
describe('[Runner Node]: lookup via HTTP Gateway supporting application/vnd.ipld.raw responses', function () { | ||
const ipfsGW = process?.env?.IPFS_GATEWAY || 'https://ipfs.io' | ||
|
||
it('looks up multiple times before failing', async () => { | ||
let decodeCallCount = 0 | ||
const rewiredGeoIp = await esmock('../src/index.js', {}, { | ||
'@ipld/dag-cbor': { | ||
decode: (...args) => { | ||
decodeCallCount += 1 | ||
if (decodeCallCount === 1) { | ||
throw new Error('Decode Failed') | ||
} | ||
return dagCborDecode(...args) | ||
} | ||
} | ||
}) | ||
|
||
const result = await rewiredGeoIp.lookup(ipfsGW, '66.6.44.4') | ||
expect(decodeCallCount).to.be.greaterThan(1) | ||
expect( | ||
result | ||
).to.be.eql({ | ||
country_name: 'USA', | ||
country_code: 'US', | ||
region_code: 'VA', | ||
city: 'Ashburn', | ||
postal_code: '20149', | ||
latitude: 39.0469, | ||
longitude: -77.4903, | ||
planet: 'Earth' | ||
}) | ||
}) | ||
}) |