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

@express-augment/storage-manager

v1.0.1

Published

A storage manager to help you manage storage (s3, fs, etc.)

Downloads

7

Readme

Augment Storage Manager

A storage manager for expressjs

The augment provides you with a facade to manage different storage options like AWS S3 or file system. ( currently only the s3 and file system storage options are added but more will be added later on. )

Concept

In different environment of your application, you may require different storage options to store your files. Eg. If your file is running on the cloud, you may need to store them on S3 buckets but doing the in a local setup may not be very efficient. It would be helpful to use the local file system instead of the buckets here to manage files during local development. The Augment storage manager lets you do just that. It provides you an easy option to switch between different storage providers or simple setup different providers for different environments. you can setup an environment variable for each environment with the name of the provider you want to use for that environment and then let storage manager take care of the rest.

Initialize an fs provider

const StorageManagerFactory = require('@express-augment/storage-manager');
const storageManager = new StorageManagerFactory('fs');
const fileStorageManager = storageManager.getManager();

Initialize an s3 (aws) provider

const StorageManagerFactory = require('@express-augment/storage-manager');
// if you have dotend setup, you can put these credentials there and storage manager will pick them up
// from process.env variable.
const storageManager = new StorageManagerFactory('aws_s3', {
    AWS_S3_REGION: 'us-east-2',
    AWS_ACCESS_KEY_ID: 'test',
    AWS_SECRET_ACCESS_KEY: 'test',
    AWS_S3_ENDPOINT: 'http://localhost:4566'
});
const s3StorageManager = storageManager.getManager();

list files/objects

// the target directory.
storageManager.setTarget('some-random-path');
// list files at path: some-random-path
storageManager.ls().then( data => console.log(data) )

read a file/object

// the target directory.
storageManager.setTarget('some-random-path');
// get file content at path: some-random-path/testfile.txt and convert it to string + log the output.
storageManager.get('testfile.txt').then( file => file.toString().then(console.log)  )

copy from a path

// the target directory.
storageManager.setTarget('some-random-path');
// copy a file from one path to another. NOTE for s3, it will look for the from path in the same bucket.
// to copy between different buckets or upload from local filesystem to s3, use the put method.
storageManager.copy('from-path', 'to-path')

delete from a path

// the target directory.
storageManager.setTarget('some-random-path');
// delete file/object at path.
storageManager.rm('delete-path')

get size for a given path

// the target directory.
storageManager.setTarget('some-random-path');
// get the total size at a given path. returns promise with result in bytes.
storageManager.size('delete-path')

write to a file

// the target directory.
storageManager.setTarget('some-random-path');
// write to file.
// NOTE:- for s3, if the argument for content is passed as string, storage manager will look for the file locally and read
// from it and publish it's content to s3 path.
storageManager.put('path', 'some-example-content')