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

@finn-no/cdn-uploader

v3.3.0

Published

Small tool uploading assets to CDN backend (Google Cloud Storage)

Downloads

154

Readme

cdn-uploader

Small tool uploading assets to CDN backend (Google Cloud Storage)

Build Status Greenkeeper badge

Requirements

You must either specify key-filename or specify credentials which is a base64 encoded JSON.stringify version of the JSON based keyfile containing credentials used when talking to Google Cloud Storage (GCS).

//base 64 encoded keyfile
const credentials = require('keyfile.json');
const credentialString = JSON.stringify(credentials);
return new Buffer(credentialString).toString('base64');

Usage

Install:

$ npm install @finn-no/cdn-uploader -g

Actual usage:

$ cdn-uploader -a test-app /tmp/cdn-assets
-- Uploaded assets --
test-app/example.jpg
test-app/css/example.css
test-app/js/example.js

Get help:

$ cdn-uploader -h
cdn-uploader [options] <assetsFolder>

Options:
  -a, --app-prefix     Application prefix used in the CDN url[string] [required]
  -k, --key-filename   JSON key file used to authenticate with Google Cloud
                       Platform.
                       If not set, the credentials option is used.      [string]
  -c, --credentials    Stringified and base64 encoded version of the JSON key
                       file used to authenticate with Google Cloud Platform.
                       Can also be set as CDN_UPLOADER_CREDENTIALS environment
                       variable                                         [string]
  -b, --bucket-name    Google Cloud Storage bucket to use.
                                              [string] [default: "fiaas-assets"]
  -p, --project-id     Google Cloud Storage projectId.
                                                 [string] [default: "fiaas-gke"]
      --cache-control  Override the cache-control header for the assets
                                   [string] [default: "public, max-age=2592000"]
  -f, --flatten        Flatten filestructure          [boolean] [default: false]
  -n, --dry-run        Print a list of which files would be uploaded   [boolean]
  -r, --resumable      Resumable upload                [boolean] [default: true]
  -V, --validation     Validation for upload           [boolean] [default: true]
  -s, --batch-size     How many files to upload in each batch
                                                         [number] [default: 100]
  -h, -?, --help       Show help                                       [boolean]
  -v, --version        Show version number                             [boolean]

All options can also be set as environment variables, using the CDN_UPLOADER_ prefix. E.g.: CDN_UPLOADER_APP_PREFIX, CDN_UPLOADER_CREDENTIALS, etc.

Excluded files

All files or folder beginning with a "." is automatically excluded (e.g. .gitignore) and will not be uploaded.

Advanced

You may also override other options if you like (handy for testing)

  • --key-filename - JSON key file used to authenticate with GCP. If not set CDN_UPLOADER_CREDENTIALS environment variable is used.
  • --bucket-name - GCS bucket to use.
  • --project-id - GCS projectId.

You can also use environment variables for these options, just use the prefix CDN_UPLOADER_.

Where does my files end up?

The files uploaded to GCS is made available on the public GCS hosting at:

https://storage.googleapis.com/<bucket-name>/<app-prefix>/<assetName>

This is again exposed by our CDN at:

https://static.finncdn.no/_c/<app-prefix>/<assetName>

Cache time?

All files uploaded to CDN is configured with Cache-Control: public, max-age=2592000, meaning that clients may cache the assets for up to 30 days.