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

@nichoth/blob-store

v0.3.3

Published

Store blobs

Downloads

3

Readme

blob-store

Store blobs in a content-addressed way. This uses @nichoth/multihash to create a unique hash for any file.

So far have only implemented a backend via cloudinary, but it would be good to implement other backends as well.

install

npm i -S @nichoth/blob-store

example

require('dotenv').config()
const BlobStore = require('@nichoth/blob-store/cloudinary')
const cloudinaryUrl = require('@nichoth/blob-store/cloudinary/url')
import { scale } from "@cloudinary/url-gen/actions/resize";
const test = require('tape')

test('create a blob store', t => {
    // this wraps the package 'cloudinary'
    // takes the same config object
    const blobStore = BlobStore({
        cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
        api_key: process.env.CLOUDINARY_API_KEY,
        api_secret: process.env.CLOUDINARY_API_SECRET
    })

    t.ok(blobStore, 'should create a blobStore')
    t.end()
})

var _hash
test('blobstore.write', t => {
    blobStore.write(file)
        // get a hash here for a given file
        .then(({ hash, response }) => {
            _hash = hash
            t.ok(hash.includes('.sha256'),
                'should return hash, and create a sha256 hash as default')
            t.ok(response, 'should return http response')
            t.equal(response.public_id, hash, 'should use the hash as filename')
            t.end()
        })
        .catch(err => {
            t.fail(err)
            t.end()
        })
})

test('get a URL', t => {
    // this wraps the package '@cloudinary/url-gen'
    // takes the same config object
    const cld = cloudinaryUrl({
        cloud: { cloudName: process.env.CLOUDINARY_CLOUD_NAME },
        url: {
            secure: true // force https, set to false to force http
        }
    })

    const url = (cld
        .image(_hash)
        .resize( scale().width(100) )
        .toURL())

    console.log(url)
    // => https://res.cloudinary.com/nichoth/image/upload/GmuzSvBeEBT5tvt1vhtRkhl1a7V8MkTqCxT4Z4jFz_s.sha256?_a=ATAMhUk0

    t.ok(url.includes('https'), 'should return an https URL')
    t.ok(url.includes(_hash), 'url should include the right filename')
    t.end()
})