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

@isobel/s3

v0.2.0

Published

--- name: S3 menu: Packages ---

Downloads

4

Readme


name: S3 menu: Packages

@isobel/s3

Enables Isobel to interface with an S3 bucket for reading and writing cache artifacts.

Creating your Amazon S3 Bucket.

Create a free account at with Amazon Web Services(aws.amazon.com), then go to Amazon S3 and create your first bucket. Name the bucket whatever you like. You can leave everything else as default or tweak to your liking.

Specify the name of your S3 Bucket in .env file

AWS_BUCKET_NAME=XXXXXXX

Get your S3 API Keys

Once your bucket is created, we need to give Isobel a way of being able to read/write securely, using API keys. There are two ways we can go here, we can either use the API keys for your admin account (which is less secure as they have full access to all of your Amazon AWS services), or we can create a API key specific for Isobel (this is more complex but is way more secure).

The quick way.

WARNING: This method uses API keys that have full access to all of your Amazon AWS services. This is not the most secure approach, so proceed at your own risk. While logged into Amazon S3, click your username at the top-right of the screen, and click 'My Security Credentials'. Underneath Access keys, create a new pair of access keys. Copy these keys into your .env file under the following keys...

AWS_ACCESS_KEY_ID=XXXXXXX
AWS_SECRET_ACCESS_KEY=XXXXXXX

The secure way (recommended)

The preferred method of giving Isobel access to S3 is to create unique AWS API keys for Isobel, with access permissions scoped to the correct S3 bucket.

Create an Access Policy

A policy is a specific permission that you grant to a user. In this case, we want to only grant permissions to read/write to out S3 bucket. While logged in to AWS, go to services > IAM, and then click 'Policies' in the sidebar. Create a new Policy using these following settings... Services - Add 'S3' Actions - tick 'GetObject', 'PutObject' and 'DeleteObject' Resources - expand the menu. In the 'Object' section, press 'Add ARN', Enter the following...

  • Bucket Name: Type in the name of your S3 Bucket. (e.g. arn:aws:s3:::my-isobel).
  • Object Name: Tick the 'Any' box.

In the next scene, name your policy 'AccessIsobel', and save it.

Create an IAM User

While logged in to AWS, go to services > IAM, and then click 'Users' in the sidebar. Create a new user, and name it whatever you like (e.g. my-isobel). Tick the box that says 'programmatic access', and click next. The next scene is permissions, click 'Attach existing policies directly', and attach the 'AccessIsobel' policy you just created.

Skip the 'tags' scene, and review/save the new IAM user. In the next scene, copy the Access Key ID and Secret Access Key, and paste them in your .env file.

AWS_ACCESS_KEY_ID=XXXXXXX
AWS_SECRET_ACCESS_KEY=XXXXXXX

You will not be able to see these credentials again in the AWS interface, but you can generate new ones later if they get forgotten.

Configure Isobel to use S3

Finally, we have to tell Isobel to use S3 as the caching strategy.

const ISOBEL = require("@isobel/core");
const S3 = require("@isobel/s3");
// import your services here

const services = [
  // initialise your services in here
];

const Isobel = new ISOBEL({
  cache: S3,
  services
});

Isobel.start().catch(error => {
  console.error("Error:", error);
  process.exit(1);
});

If you would like to, you could also choose to run the filesystem cache while in development.

const Isobel = new ISOBEL({
  cache: process.env.NODE_ENV === "production" ? S3 : fileSystem,
  services
});

Expected env vars

S3 interface will not work unless these environment variables are specified.

  • AWS_BUCKET_NAME
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY