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

@smallmultiples/s3

v1.0.1

Published

Functions for uploading files/applications to s3

Downloads

4

Readme

NCalls

Methods for deploying an SPA to s3 and uploading individual files.

Usage

var aws = { 
    key: '', 
    secret: '', 
    region: 'ap-southeast-1', 
    bucket: 'smallmu-sandbox'
}

// Deploying an SPA
var deployFactory = require('@smallmultiples/s3')
var deploy = deployFactory({ aws, aws })
deploy('path/to/app/**/*', 'path/to/destination', {
    base: 'path/to/app'
    versioning: false
}, function (err) {
    if (err) console.error(err)
})

// Uploading an individual file
var upload = require('@smallmultiples/s3/file')
upload({
    src: 'path/to/src.ext'
    dest: 'path/to/dest.ext'
    aws: aws
    gzip: true
}, function (err) {
    if (err) console.error(err)
})

API

deployFactory(options)

Create the deploy() function, takes an options object, which has the following properties:

  • aws: Object containing aws credentials:
    • key: Your aws Access Key
    • secret: Your aws Secret
    • region: The region your s3 bucket lives in
    • bucket: The bucket to upload to
  • concurrent: How many concurrent uploads to run. Defaults to 20.
  • cache: An object describing the cache settings as described by gulp-awspublish-router
    • cacheTime: How long to cache for in milliseconds. Defaults to 1 year.
  • routes: A function that given a file path returns an object describing how it should be uploaded. See gulp-awspublish-router for more information. Defaults to:
    function (path) {
        return {
            // Text assets get gzipped
            '^.+\.(?:json|js|css|topojson|geojson|svg)$': {
                gzip: true
              , key: path + '$&'
            }
            // HTML gets shorter cache time
          , '^.+\.html$': {
                gzip: true
              , key: path + '$&'
              , cacheTime: 1000 * 60 * 5 // 5 minutes
            }
            // Passthrough for everything else
          , '^.+$': path + '$&'
        }
    }

deploy(src, dest, options, callback)

Deploys the files described by src to dest, calling callback when it's done or there is an error.

  • src: Gulp style file path or array of file paths.
  • dest: Destination path to upload to, e.g., '/your/app'
  • options: Deploy specific options:
    • base: The base path of the src to remove when deploying files to dest.
    • versioning: Whether to turn on versioning. Default true. We use gulp-rev-all.
  • callback(err): Called after all files are uploaded, if there was an error it will be the first argument.

uploadFile(options, callback)

Uploads a single file to a single location on s3. Lets you specify cache time and if you want it gzipped or not.

  • options: An object with the following parameters:
    • src: The file to upload
    • dest: The place to put it on s3
    • aws: Your aws credentials object:
      • key: Your aws Access Key
      • secret: Your aws Secret
      • region: The region your s3 bucket lives in
      • bucket: The bucket to upload to
    • cache: An object describing the cache settings as described by gulp-awspublish-router, or an integer value of milliseconds to cache for (defaults to 1 year)
    • gzip: Whether or not to gzip the file. Default false.