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 🙏

© 2026 – Pkg Stats / Ryan Hefner

spacecube

v1.1.1

Published

SpaceCube is a wrapper API and CLI tool for working with Digital Ocean Spaces or other S3 compatible services. It can be used stand-alone as a CLI application or used as a library in your own JS/TS projects.

Downloads

31

Readme

SpaceCube

SpaceCube is a wrapper API and CLI tool for working with Digital Ocean Spaces or other S3 compatible services. It can be used stand-alone as a CLI application or used as a library in your own JS/TS projects.

The CLI and the API share nearly the exact same interface which makes it straight-forward to prototype workflows with the CLI and then formalize them into API calls.

CLI Example

% spacecube buckets
[
  "bucket1",
  "bucket2",
  "bucket3"
]

% spacecube upload -r -v myBucket dist .
Uploading dist/SpaceCube.js
Uploading dist/SpaceCubeCLI.js

API Example:

import * as Space from "./SpaceCube";
const creds: Space.Creds = {
  "s3_endpoint": "https://sfo3.digitaloceanspaces.com",
  "s3_region": "us-east-1",
  "s3_access_key": "DO.................",
  "s3_secret_key": "dZ................." 
}
const space = new Space.SpaceCube(creds);
async function example() {
  const listing = await space.listBuckets();
  console.log(listing);
}
example();

This is not intended to be the fastest or most robust S3 tool around. It's purpose is to stay simple and fill a niche for "indie" developers who don't want waste their weekends reading S3 SDK docs.

Note: This project is currently downloading and uploading files synchronously which can be pretty slow for very large operations.

Install

To install spacecube as a dependency of your app do:

npm install spacecube

If you want the CLI as a globally runnable command do:

npm install -g spacecube

You can also run spacecube via npx:

npx spacecube

If you think spacecube is too long to type do something like:

alias s3=spacecube

Using the CLI

By default the cli is available at spacecube when this package is installed globally.

Authentication

This program needs a credentials json file to authenticate. The file looks something like this:

{
    "s3_endpoint": "https://sfo3.digitaloceanspaces.com",
    "s3_region": "us-east-1",
    "s3_access_key": "DO.................",
    "s3_secret_key": "dZ................."
}
  • The CLI will look in one of two places for your credentials json file.
    • By default it will look for ~/.spacecube.json.
    • If the -c flag is used it will look for the path following the flag.

You can create a new credentials file with the auth command or be guided through creating it with the auth-wiz command.

Usage

Options:
  -V, --version                                         output the version number
  -h, --help                                            display help for command

Commands:
  auth [options]                                        create a credentials file
  auth-wizard                                           create a credentials file interactively
  bucket-new [options] <bucket>                         create a new bucket
  bucket-delete [options] <bucket>                      delete a bucket
  buckets [options]                                     list all buckets
  list [options] <bucket>                               list files
  upload [options] <bucket> <localPath> <remotePath>    upload a file
  download [options] <bucket> <remotePath> <localPath>  download a file
  delete [options] <bucket> <remotePath>                delete a file
  get [options] <bucket> <remotePath>                   print file contents
  put [options] <bucket> <remotePath> <data>            put a file (upload or update)
  help [command]                                        display help for command

Using the API

Basic Example

Include the library in your project:

// Get a list of files at myBucket:myDir/
import * as Space from "spacecube";
const creds: Space.Creds = {
  "s3_endpoint": "https://sfo3.digitaloceanspaces.com",
  "s3_region": "us-east-1",
  "s3_access_key": "DO.................",
  "s3_secret_key": "dZ................." 
}
const space = new Space.Cube(creds);
async function example() {
  const opt: Space.ListOptions = {
    bucket: 'myBucket';
    remotePath: 'myDir/';
  }
  const listing = await space.list(opt);
  console.log(listing);
}
example();

Credentials

The API takes credentials in the same format as the CLI. The API constructor expects an object like this:

type Creds = {
    s3_endpoint: string;
    s3_region: string;
    s3_access_key: string;
    s3_secret_key: string;
};

API Responses

Calls to the API always return an object like this:

type Res = {
    rc: number;
    data?: any;
    err?: any;
};
  • rc - the return code (0 == ok)
  • data? - the return data (if any)
  • err? - the error that was encountered (if any)

API Methods

All API methods are async.

createBucket(bucket: string)

Creates a new bucket with the given bucket name.

deleteBucket(bucket: string)

Delete a bucket with the given name.

listBuckets()

Returns a list of your buckets.

list(opt: ListOptions)

type ListOptions = {
    bucket: string;
    remotePath?: string; // Filter by path
}

Returns a list of items in the given bucket (1k item limit).

listAll(opt: ListOptions)

type ListOptions = {
    bucket: string;
    remotePath?: string; // Filter by path
}

Returns a list of items in the given bucket. Slower than list but has no limit on how many items can be returned.

upload(opt: UploadOptions)

type UploadOptions = {
    bucket: string;
    localPath: string;
    remotePath: string;
    publicAccess?: boolean;
    recursive?: boolean;
    mimeTypeOverride?: string;
    verbose?: boolean;
}

Uploads a file or directory to the given bucket. Use the recursive option to upload directories.

download(opt: DownloadOptions)

type DownloadOptions = {
    bucket: string;
    remotePath: string;
    localPath: string;
    recursive?: boolean;
    verbose?: boolean;
}

Downloads a file or directory from the given bucket. Use the recursive option to download directories.

delete(opt: DeleteOptions)

type DeleteOptions = {
    bucket: string;
    remotePath: string;
    recursive?: boolean;
    verbose?: boolean;
}

Deletes a file or directory from the given bucket. Use the recursive option to download directories.

get(opt: GetOptions)

type GetOptions = {
    bucket: string;
    remotePath: string;
}

Get the file contents and return it. Does not "download" the file.

put(opt: PutOptions)

type PutOptions = {
    bucket: string;
    remotePath: string;
    data: any;
    publicAccess?: boolean;
    mimeTypeOverride?: string;
}

Put some data directly from RAM into the bucket. Does not "upload" a file.