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

aws-thin-s3

v0.10.2

Published

aws thin S3 client

Downloads

109

Readme

NPM version JavaScript Style Guide

What is this for?

The AWS JS SDK does a lot. For Lambdas is does too much; it incurs a 1-2 seconds cold-start time, depending on what you load from it. Even for directly loading the smaller clients, it loads 800kb of code from "core". If you really need to squeeze out that extra performance for Lambda cold-starts, you need a smaller client. This client, with dependencies, is ~15kb. If you are using other thin clients, those dependencies are identical, and share 8kb of the size (its mostly the AWS V4 request signer). This should cost cold-start no more than 100ms, even on the smallest lambda configuration size.

aws-thin-s3 does not attempt to offer a complete API replacement, but it is a drop-in replacement for the API it does cover. For ease of use the callback parameter can be ommitted from all async calls to get a Promise instead.

Installation

npm i aws-thin-s3

API

This thin client is designed for basic file use with S3. It does not support any bucket-level operations, and there are currently no plans to add this. The supported API should be a drop-in replacement for the Official SDK API, with the addition of promise-returning functions when the callback is ommitted. If you would like to add additional support you can open a Github issue or create a Pull Request.

Full API Support - This function accepts all input paramaters accepted by the Official SDK, and the response matches the Official SDK exactly. You should be able to replace the thin client with the official client without changing any other code.

Partial API Support- This function accepts some of the input parameters accepted but the Offical SDK, but not all. The response matches the Official SDK, but may not include all properties.

  • getObject - Full API Support, see docs
  • deleteObject - Full API Support, see docs
  • putObject - Partial API Support, input supports Bucket, Key, Body and ContentType; see docs

Using the logger

The client allows a logger to be passed into the constructor that will log at various levels, allowing the consumer to control where and how much logging this module produces. The logger supports 4 optional properties: debug, info, warn, and error. Only the provided functions will be used.

  • Debug - The noisiest level. Produces frequent logs which may include sensitive information like full HTTP(s) responses. This is not safe for production.
  • Info - Standard information about module actions; does not log response data but does log input parameters. This should be safe for production unless requests are sensitive.
  • Warn - Indicates a non-fatal error or condition that may require attention. Recommended for production.
  • Error - Fatal errors, does not log response data but will log input parameters.

Example Logger

let exampleLogger = {
  debug: (...args) => console.log(...args.map(a => require('util').inspect(a, { colors: true, depth: null }))), // eslint-disable-line
  error: (...args) => {
    // do something special
    console.error('yo, something broke', ...args)
  },
  // warn: console.log.bind(console)
  info: console.log.bind(console)
}
let client = s3({ logger: exampleLogger, region: 'us-west-2' })

This logger will log teriminal-friendly debug messages, erros, and info, but no warnings.