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

bstorejs

v0.1.5

Published

API Interface for Bstore, a simple blob store.

Downloads

7

Readme

bstore NPM Package React Package Demo

Install

npm i bstorejs

Import

import { put, get, list, del } from 'bstorejs';

Usage

Environment Variables

export BSTORE_HOST="your_bstore_host" # e.g your `host` value from `conf.yml`
export BSTORE_READ_WRITE_KEY="your_read_write_key" # e.g the same `BSTORE_READ_WRITE_KEY` value from `keys.env`

Accepted File/Blob Types

  • Bun
  • Web
  • Blob
/* Bun File https://bun.sh/docs/api/file-io */
const file = Bun.file("music.mp4");

/* Web File https://developer.mozilla.org/en-US/docs/Web/API/File */
const buffer = await fs.readFile("music.mp4");
const file = new File([buffer], "music.mp4");

/* Blob https://nodejs.org/api/buffer.html#class-blob */
const buffer = await fs.readFile("music.mp4");
const file = new Blob([buffer], { type: "video/mp4" });
  1. Upload a File - put
const res = await put(file, 'videos/music.mp4', 'public');
console.log(res.url)
  1. Download a File - get
const res = await get('videos/music.mp4', 'public');
const file = res.file as File;
await Bun.write('output/music.mp4', file);
  1. Delete a File - del
const res = await del('hentai/image.png', 'private');
console.log(res.status)
  1. Delete a Directory
  • Must specify with * to prevent accidental deletes.
const res = await del('tmp_data/*', 'public');
console.log(res.status)
  1. List a Directory
const res = await list('images/', 'public');
console.log(res.files)

Serving Public Files

<img src="http://localhost:8080/bstore/image/image.mp4" class="max-w-full max-h-full object-contain"></img>
<embed src="http://localhost:8080/bstore/books/book.mp4" type="application/pdf" className="w-full h-full border-0"></embed>

Steaming Public Videos

Example Using a .mp4 Video

  • Also Accepts: .mp4, .webm, .ogg, .wmv, .mov, .avchd, .av1
  1. Upload the .mp4 Video
const res = await put(file, 'music/song.mp4', 'public');
console.log(res.url)
{
    "url": "http://localhost:8080/bstore/music/song.mp4",
    "message": "Public File Uploaded Successfully",
    "stream": {
        "hls_url": "http://localhost:8080/bstore/music/song/index.m3u8",
        "dash_url": "http://localhost:8080/bstore/music/song/index.mpd"
    }
}
  1. Serve the .mp4, .mpd, and .m3u8 Files
<head>
  <script src="https://cdn.dashjs.org/latest/dash.all.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
</head>
<body>
  <video id="videoPlayer" controls className="w-full h-full border-0">
    <source src="http://localhost:8080/bstore/music/song/index.m3u8" type="application/x-mpegURL">
    <source src="http://localhost:8080/bstore/music/song/index.mpd" type="application/dash+xml">
    <source src="http://localhost:8080/bstore/music/song.mp4" type="video/mp4">
  </video>
  <script>
    var video = document.querySelector("#videoPlayer");
    var dash_url = "http://localhost:8080/bstore/music/song/index.mpd";
    var hls_url = "http://localhost:8080/bstore/music/song/index.m3u8";

    if (Hls.isSupported()) {
      var hls = new Hls();
      hls.loadSource(hls_url);
      hls.attachMedia(video);
    } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
      video.src = hls_url;
    } else if (dashjs.supportsMediaSource()) {
      var player = dashjs.MediaPlayer().create();
      player.initialize(video, dash_url, true);
    }
  </script>
</body>