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

gatsby-source-s3-asset

v1.4.0

Published

GatsbyJS plugin to source assets from S3-compliant APIs.

Downloads

29

Readme

CircleCI npm Maintainability codecov

What is this?

gatsby-source-s3-asset is a GatsbyJS Source plugin to obtain objects from any S3-compliant API[1] as GatsbyJS nodes.

[1] This includes AWS S3, of course, as well as third-party solutions like Digital Ocean Spaces, or open source / self-hosted products like MinIO.

This plugin is based on gatsby-source-s3-image. The major difference is that this version does not download any files nor analyzes their contents in any way. The goal is just to list assets and provide their publicly-accessible URLs to gastby's internal GraphQL.

But I can just query S3 manually client-side...

Sure, knock yourself out. But there are a few benefits you get out-of-the-box with this package:

  • Native integration with Gatsby's GraphQL data ontology, of course. You just provide the bucket details (and IAM credentials, if not public, which is recommended).

Usage

Setup

Add the dependency to your package.json:

$ yarn add gatsby-source-s3-asset
$ # Or:
$ npm install --save gatsby-source-s3-asset

Next, register the plugin with the GatsbyJS runtime in the plugins field exported from your gatsby-config.js file, filling in the values to point to wherever your bucket is hosted:

const sourceS3 = {
  resolve: 'gatsby-source-s3-asset',
  options: {
    bucketName: 'jesse.pics',
    domain: null, // [optional] Not necessary to define for AWS S3; defaults to `s3.amazonaws.com`
    protocol: 'https', // [optional] Default to `https`.
    publicDomain: null, // [optional] Use this domain to construct the public URL for the assets
    accessKeyId: 'your AWS Access Key', // You can also use something like process.env.AWS_ACCESS_KEY
    secretAccessKey: 'Your AWS Secret Access Key',
  },
}

const plugins = [
  sourceS3,
  // ...
]

module.exports = { plugins }

Querying

As mentioned above, gatsby-source-s3-asset exposes nodes of type S3Asset:

interface S3AssetNode {
  id: string
  LastModified: Date
  ETag: string
  Key: string
  internal: {
    content: string
    contentDigest: string
    mediaType: string
    type: string
  }
}

Nota Bene: Gatsby Version Compatibility

gatsby-source-s3-asset is compatible only with Gatsby V2,