Skip to content

Commit

Permalink
feat(buckets): add bucket.links
Browse files Browse the repository at this point in the history
Signed-off-by: andrew <[email protected]>
  • Loading branch information
andrewxhill committed May 19, 2020
1 parent 0d32ea2 commit 803c51c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/buckets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ describe('Buckets...', () => {
expect(rep.item?.isdir).to.be.false
})

it('should list bucket links', async () => {
const rootKey = buck.root?.key || ''

const rep = await client.links(rootKey)
expect(rep.url).to.not.equal('')
expect(rep.www).to.not.equal('')
expect(rep.ipns).to.not.equal('')
})

it('should pull files by path and write to file on node', async function () {
if (isBrowser) return this.skip()
// Bucket path
Expand Down
13 changes: 13 additions & 0 deletions src/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ export class Buckets {
return res.toObject().rootsList
}

/**
* Returns a list of bucket links.
* @param key Unique (IPNS compatible) identifier key for a bucket.
* @param ctx Context object containing web-gRPC headers and settings.
*/
async links(key: string, ctx?: Context) {
logger.debug('link request')
const req = new pb.LinksRequest()
req.setKey(key)
const res: pb.LinksReply = await this.unary(API.Links, req, ctx)
return res.toObject()
}

/**
* Returns information about a bucket path.
* @param key Unique (IPNS compatible) identifier key for a bucket.
Expand Down

0 comments on commit 803c51c

Please sign in to comment.