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

@datagraphics/delivery

v0.6.0

Published

Push and pull assets to and from S3 the Data Graphics way.

Downloads

76

Readme

@datagraphics/delivery is a way to push and pull assets to and from S3 the Data Graphics way!

Installation

@datagraphics/delivery is available via npm.

npm install -D @datagraphics/delivery

Usage

TK TK

API

Table of Contents

Delivery

Extends EventEmitter

The base class for @datagraphics/delivery. Create an instance of Delivery to set an interface with S3.

Parameters

  • options {bucket: string, basePath: string?, useAccelerateEndpoint: boolean?, shouldBeCached: function (path: string): boolean?}
    • options.bucket The bucket on S3 to interact with
    • options.basePath A pre-defined base path for all interactions with S3. Useful for establishing the slug or prefix of an upload. (optional, default '')
    • options.useAccelerateEndpoint If true, use the Accelerate endpoint (optional, default false)
    • options.shouldBeCached A function used to determine whether a file should receive long-lived cache headers. (optional, default defaultShouldBeCached)

Examples

const delivery = new Delivery({
 bucket: 'apps.thebignews.com',
 basePath: 'our-great-project',
});

uploadFile

Uploads a single file to S3.

Parameters
  • file string The path to the file to upload
  • path string Where to upload the file relative to the base path
  • options {isPublic: boolean?, shouldCache: boolean?, cacheControlOverride: string?} (optional, default {})
    • options.isPublic Whether a file should be made public or not on upload (optional, default false)
    • options.shouldCache Whether a file should have cache headers applied (optional, default false)
    • options.cacheControlOverride A custom Cache-Control value that will override the built-in lookup if shouldCache is true
Examples
const result = await delivery.uploadFile(
  './data/counties.json', // path to the file on local drive
  'counties.json', // the key to give the file in S3, combined with `basePath`
  {
    isPublic: true,
  }
);

Returns Promise<UploadOutput>

uploadFiles

Upload a directory of files to S3.

Parameters
  • dir string The directory to upload to S3
  • options {prefix: string?, isPublic: boolean?, shouldCache: boolean?, cacheControlOverride: string?} (optional, default {})
    • options.prefix The prefix to add to the uploaded file's path (optional, default '')
    • options.isPublic Whether all files uploaded should be made public (optional, default false)
    • options.shouldCache Whether all files uploaded should get cache headers (optional, default false)
    • options.cacheControlOverride A custom Cache-Control value that will override the built-in lookup if shouldCache is true
Examples
const result = await delivery.uploadFiles(
  './dist/', // path to the directory on local drive to upload
  {
    isPublic: true,
    prefix: 'output', // the key prefix to combine with `basePath`
  }
);

downloadFile

Downloads a file from S3 to the local disk.

Parameters
  • path string The path to the file to download
  • dest string Where to put the file on the local disk
  • options {s3ETag: string?} (optional, default {})
    • options.s3ETag If the ETag from S3 is already known, it can be provided here
Examples
const result = await delivery.downloadFile(
  'output/data.json', // key of file on S3 to download
  './downloaded/data.json', // where to download the file to the local drive
);

downloadFiles

Downloads multiple files from a prefix on S3.

Parameters
  • prefix string The prefix to the directory on S3 to download from
  • dir string Where to put all the files on the local disk
Examples
const result = await delivery.downloadFiles(
  'production', // the key of the directory on S3 to download from
  './downloaded/', // where to download the files to the local drive
);

How outputs are structured

These represent the output objects from Delivery's commands.

DownloadOutput

What downloadFile and downloadFiles returns.

Key

The file's path on S3.

Type: string

isIdentical

Whether the file was identical on S3 or locally and was skipped.

Type: boolean

UploadOutput

What uploadFile and uploadFiles returns.

ETag

The file's ETag.

Type: string

Key

The file's path on S3.

Type: string

isIdentical

Whether the file was identical on S3 or locally and was skipped.

Type: boolean

isPublic

This file was made public on upload.

Type: boolean

size

The size of the uploaded file in bytes.

Type: number

Delivery#upload

Type: UploadOutput

License

MIT