Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

catbox-s3

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

catbox-s3

Amazon S3 adapter for catbox

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

catbox-s3

Amazon S3 adapter for catbox.

Build Status Current Version

Options

  • bucket - the S3 bucket. You need to have write access for it.
  • accessKeyId - the Amazon access key.
  • secretAccessKey - the Amazon secret access key.
  • region - the Amazon S3 region. (If you don't specify a region, the bucket will be created in US Standard.)
  • endpoint - the S3 endpoint URL. (If you don't specify an endpoint, the bucket will be created at Amazon S3 using the provided region if any)
  • setACL - defaults to true, if set to false, not acl is set for the objects
  • ACL - the ACL to set if setACL is not false, defaults to public-read

Caching binary data

At the moment, Hapi doesn't support caching of non-JSONifiable responses (like Streams or Buffers, see #1948). If you want to use catbox-s3 for binary data, you have to handle it manually in your request handler:

var Catbox = require('catbox');

// On hapi server initialization:
// 1) Create a new catbox client instance
var cache  = new Catbox.Client(require('catbox-s3'), {
    accessKeyId     : /* ... */,
    secretAccessKey : /* ... */,
    region          : /* ... (optional) */,
    bucket          : /* ... */
});

// 2) Inititalize the caching
cache.start(function (err) {

    if (err) { console.error(err); }
    /* ... */
});

// Your route's request handler
var handler = function (request, reply) {

    var cacheKey = {
        id      : /* cache item id */,
        segment : /* cache segment name */
    };

    cache.get(cacheKey, function (err, result) {

        if (result) {
            return reply(result.item).type(/* response content type */);
        }

        yourBusinessLogic(function (err, data) {

            cache.set(cacheKey, data, /* expiration in ms */, function (err) {

                /* ... */
            });
            reply(result.item).type(/* response content type */);
        });
    });
};

Running tests

In order to run the tests, set the aforementioned options as environment variables:

S3_ACCESS_KEY=<YOURKEY> S3_SECRET_KEY=<YOURSECRET> S3_REGION=<REGION> S3_BUCKET=<YOURBUCKET> npm test

License

MIT

Keywords

FAQs

Package last updated on 14 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc