1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

Add example Aquarius instantiation doc in README.

Use LoggerInstance alias in Aquarius.test.ts.
This commit is contained in:
Jorge Shirai 2020-01-20 11:38:20 +01:00
parent df1c4fafd7
commit 791d22cb92
2 changed files with 15 additions and 2 deletions

View File

@ -72,6 +72,19 @@ const ocean: Ocean = await Ocean.getInstance({
For an overview of endpoint configurations making up various Ocean networks, please refer to [`.env.local.example`](https://github.com/oceanprotocol/commons/blob/master/client/.env.local.example) from commons.
Optionally, you can initialize an Aquarius connection without relying on the rest of Ocean to be loaded. This is useful for outputting asset metadata stored in Aquarius without the need to configure Web3 and all other Ocean Protocol network connections.
```js
import { Ocean, Aquarius, Logger } from 'squid'
const aquarius = new Aquarius('http://localhost:5000', Logger)
const asset = aquarius.retrieveDDO('did:op:e6fda48e8d814d5d9655645aac3c046cc87528dbc1a9449799e579d7b83d1360')
const ocean = await Ocean.getInstance({ ... })
// Aquarius will still be available under ocean.aquarius, just later
const asset = ocean.aquarius.retrieveDDO('did:op:e6fda48e8d814d5d9655645aac3c046cc87528dbc1a9449799e579d7b83d1360')
```
### Examples
You can see how `squid-js` is used on:

View File

@ -5,7 +5,7 @@ import { Aquarius, SearchQuery } from '../../src/aquarius/Aquarius'
import { DDO } from '../../src/ddo/DDO'
import DID from '../../src/ocean/DID'
import config from '../config'
import { Logger } from '../../src/utils'
import { LoggerInstance } from '../../src/utils'
use(spies)
@ -99,7 +99,7 @@ describe('Aquarius', () => {
})
it('should query metadata by text with a new instance', async () => {
const aquariusNew = new Aquarius(config.aquariusUri, new Logger())
const aquariusNew = new Aquarius(config.aquariusUri, LoggerInstance)
spy.on(aquariusNew.fetch, 'get', () => reponsify(getResults([new DDO()])))
const result = await aquariusNew.queryMetadataByText(query)