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

scube

v2.1.0

Published

Manage your S3 buckets

Downloads

53

Readme

scube Build status for Scube

Manage your S3 buckets

Scube is just a thin convenience wrapper around the AWS SDK, specifically for S3.

Why?

  • Easier to use with async / await & Promises. All methods return a Promise, without the need to call .promise() every time, so your code remains DRY.
  • Uses idiomatic, camel case JavaScript property names (e.g. bucket), unlike the official SDK, which uses Pascal case names (e.g. Bucket).
  • Encourages best practices, like hostname compliant bucket names, by requiring and validating certain configuration in the constructor, while still allowing you to override these for each request.
  • Provides helpful utilities and default configuration for simulating directories on S3 with / as a separator.

Install

npm install scube

Usage

Scube uses the philosophy that apps generally want to perform actions on a single bucket, so we force you to set that bucket as the default and then use the Scube instance to represent the bucket.

Below, we create my-bucket on S3.

const Scube = require('scube');

const myBucket = new Scube({
    bucket    : 'my-bucket',
    publicKey : process.env.AWS_ACCESS_KEY_ID,
    secretKey : process.env.AWS_SECRET_ACCESS_KEY
});
myBucket.createBucket().then((data) => {
    console.log('Bucket created:', data.location);
});

_Note that you can always pass bucket to each call to override the default bucket, but we encourage you to make a new Scube instance instead.

You can also work with directories as first-class citizens.

myBucket.listDir({ prefix : 'foo' }).then((data) => {
    console.log('Directory contents:', data.contents);
});

Delete a directory.

myBucket.deleteDir({ prefix : 'foo' }).then((data) => {
    console.log('Directory deleted:', data.prefix);
});

API

Please see Amazon's API documentation for details on the option and response properties.

new Scube(option)

Returns a new instance.

option

Type: object

The default configuration for all client actions. You can override its values for specific calls, if needed.

bucket

Type: string

The bucket name to use. A bucket is a unique, worldwide namespace to store your data in. Choose it carefully.

delimiter

Type: string Default: /

The delimiter character to use. Helpful to group together keys starting with a prefix not followed by a delimiter.

forcePathStyle

Type: boolean Default: false

Whether to use path style requests, as in s3.amazonaws.com/<bucket> instead of <bucket>.s3.amazonaws.com.

publicKey

Type: string

The public part of your credential keypair for authenticating with AWS.

region

Type: string Default: us-east-1

The availability zone for your bucket.

secretKey

Type: string

The private part of your credential keypair for authenticating with AWS.

Instance

Most of the official SDK methods are exposed via an equivalent Promise-based counterpart. The ones below are unique to this library.

.listDir(option)

List all keys within the option.prefix directory.

.deletePrefix(option)

Delete all keys that start with option.prefix.

.deleteDir(option)

Delete all keys within the option.prefix directory.

.s3

The underlying AWS SDK being used. This is useful when you want to use streams instead of Promises. Note that if you use streams a lot, you are probably better off just using the AWS SDK directly instead of via Scube.

Related

Contributing

See our contributing guidelines for more details.

  1. Fork it.
  2. Make a feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.

License

MPL-2.0 © Seth Holladay

Go make something, dang it.