Skip to content

A storage abstraction layer for Node.js that removes any difference among multiple public cloud storage services and local filesystems

License

Notifications You must be signed in to change notification settings

andrew-hu368/storagebus

 
 

Repository files navigation

Storage🚌

CI Coverage Status CodeQL OSSAR semantic-release: angular All Contributors

Storagebus is a storage abstraction layer for Node.js that removes any difference among multiple public cloud storage services and local filesystems.

Usage

You can use Storagebus with your filesystem, AWS and GCP:

const { Storage } = require("storage/local");
// const { Storage } = require('storage/aws')
// const { Storage } = require('storage/gcp')
const { Readable } = require("node:stream");

const storage = new Storage({
  rootFolder: "path/to/folder",
});
// const storage = new Storage({
//  bucket: 'your-aws-bucket';
//  region: 'your-aws-region';
//  accessKeyId: 'your-aws-access-key';
//  secretAccessKey: 'your-aws-secret-access-key';
// })
// const storage = new Storage({
//  bucket: 'your-gcp-bucket';
//  projectId: 'your-gcp-project-id';
//  clientEmail: 'your-gcp-client-email';
//  privateKey: 'your-gcp-private-key';
// })

async function main() {
  // Your readable stream
  const readable = Readable.from("Hello, world!");

  // write a file
  const writtenFileString = await storage.write("your-file.txt", readable);

  // read a file from your storage
  const fileReadable = await storage.read("your-file.txt");

  // check for file existance in your storage
  const exist = await storage.exists("your-file.txt");

  // copy file
  const copiedFileString = await storage.copy(
    "your-file.txt",
    "your-file-copy.txt"
  );

  // move a file
  const movedFileString = await storage.move(
    "your-file-copy.txt",
    "moved/your-file-copy.txt"
  );

  // delete a file
  await storage.remove("your-file.txt");
}

Contribute to this project

  1. Clone this repository

    git clone [email protected]:github.com/ducktors/storagebus.git

  2. Move inside repository folder

    cd storagebus

  3. Install dependencies

    pnpm install

  4. Run the project in development mode

    pnpm dev

How to commit

This repo uses Semantic Release with Conventional Commits. Releases are automatically created based on the type of commit message: feat for minor and fix for patch.

feat: new feature ---> 1.x.0
fix: fix a bug ---> 1.0.x

Contributors

Maksim Sinik
Maksim Sinik

💻 ⚠️ 📖 🚧 🤔 🧑‍🏫
Matteo Vivona
Matteo Vivona

🚇 🛡️ 📖

About

A storage abstraction layer for Node.js that removes any difference among multiple public cloud storage services and local filesystems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.1%
  • Other 0.9%