npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dat-storage-client

v1.0.0

Published

A fetch-based API for interacting with dat storage providers

Downloads

4

Readme

dat-storage-client

A fetch-based API for interacting with dat storage providers

Uses cross-fetch for HTTP requests, so it should work in many environments. Based on DEP-0003.

npm i -s dat-storage-client

Usage

const DatStorageClient = require('dat-storage-client')

const SERVICE_URL = 'https://hashbase.io'

const client = new DatStorageClient(SERVICE_URL)

await client.login(username, password)

await client.add({
  url: 'dat://60c525b5589a5099aa3610a8ee550dcd454c3e118f7ac93b7d41b6b850272330'
})

const dats = await client.list()

API

const client = new DatStorageClient(url, sessionToken)

Initialize a new client (scoped to a given provider).

The url is the root URL of your storage provider (e.g. https://hashbase.io).

You can optionally pass in a sessionToken if you've saved one from a previous session.

client.sessionToken

Get the current session token. Will be set to null if not logged in. This session token will get sent as part of every request in the authorization header as a Bearer Token.

client.url

Get the URL of the storage provider for this client

const {sessionToken} = await client.login({username, password})

Login to the storage provider using your username and password. This will save your sessionToken to the client so that it will be used in subsequent requests. You can save the sessionToken somewhere to use with the client and reduce login attempts.

await client.logout()

Logout of the storage provider. You need to be logged in first.

const {username, email} = await client.account()

Get the info about the account that's currently logged in.

const {items} = await client.list()

List the items that have been added to this storage provider. The items include a name, url, title, description and a list of additionalUrls that it can be accessed at. You must be logged in for this to work.

await client.add({url, name, domains})

Add an archive to the storage provider. Only the url is required. You must be logged in for this to work.

await client.remove({url})

Remove an archive from the storage provider. You must be logged in for this to work.

const {url, name, title, description} = await client.get(key)

Get information about a given archive. The key must be the contents of the key for that archive. E.g. 60c525b5589a5099aa3610a8ee550dcd454c3e118f7ac93b7d41b6b850272330. You must be logged in for this to work.

await client.update(key, {name, domains})

Update information for a given archive. You must be logged in for this to work.