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

moleculer-flydrive

v0.1.1

Published

An addon based in @slynova/flydrive for moleculer for storage managment

Downloads

3

Readme

Moleculer logo

moleculer-flydrive

Fluent storage manager service with Node Flydrive.
You need to install @slynova/node-flydrive

Features

  • Local
  • Amazon S3 (You need to install aws-sdk package to be able to use this driver)
  • Digital Ocean Spaces (You need to install aws-sdk package to be able to use this driver)
  • FTP (You need to install jsftp package to be able to use this driver)
  • Possibility to register a custome driver like Google Drive driver

Instalation

npm install moleculer-flydrive

Usage

With no settings (it will mount local storage driver by default with the current directory as root dir)

"use strict"
const FlyDrive = require("moleculer-flydrive");
const { ServiceBroker } = require("moleculer");
const broker = new ServiceBroker();
broker.createService(FlyDrive(),{
  actions: {
    async someAction(ctx){
      //let result = await this.storage.disk().exists("some-file.txt");
      //let result = await this.storage.disk("local").exists("some-file.txt");
      let result = await this.storage.exists("some-file.txt");//will use the default storage defined
      if(result){
        await this.storage.delete("some-file.txt");
      }
    }
  }
})

With settings

"use strict"
const FlyDrive = require("moleculer-flydrive");
const { ServiceBroker } = require("moleculer");
const broker = new ServiceBroker();
//when true passed as param the service will try to create the root dir
broker.createService(FlyDrive(true),{
  settings:{
    STORAGE_ROOT:"<a path>",
    storageConfig:{
      default: "local",
      disks:{
        local: {
          driver: "local"
        },
        s3: {
          driver: 's3',
          key: 'AWS_S3_KEY',
          secret: 'AWS_S3_SECRET',
          region: 'AWS_S3_REGION',
          bucket: 'AWS_S3_BUCKET'
        },
        ftp: {
          driver: 'ftp',
          host: 'FTP_HOST',
          port: 21,
          user: 'FTP_USER',
          pass: 'FTP_PASS',
          longLive: false
        },
      }
    }
  },
  actions: {
    async someAction(ctx){
      //let result = await this.storage.disk().exists("some-file.txt");
      //let result = await this.storage.disk("s3").exists("some-file.txt");
      let result = await this.storage.exists("some-file.txt");//will use the default storage defined
      if(result){
        await this.storage.delete("some-file.txt");
      }
    }
  }
})

Register a custom drive

"use strict"
const FlyDrive = require("moleculer-flydrive");
const GoogleDrive = require("flydrive-google-drive");
const { ServiceBroker } = require("moleculer");
const broker = new ServiceBroker();
//when true passed as param the service will try to create the root dir
broker.createService(FlyDrive(true),{
  settings:{
    STORAGE_ROOT:"<a path>",
    defaultStorage: "local",
    storageConfig:{
      disks:{
        local: {
          driver: "local"
        },
        s3: {
          driver: 's3',
          key: 'AWS_S3_KEY',
          secret: 'AWS_S3_SECRET',
          region: 'AWS_S3_REGION',
          bucket: 'AWS_S3_BUCKET'
        },
        ftp: {
          driver: 'ftp',
          host: 'FTP_HOST',
          port: 21,
          user: 'FTP_USER',
          pass: 'FTP_PASS',
          longLive: false
        },
        //register the driver configuration
        drive: {
          driver: "drive",
          clientId: "GOOGLE_DRIVE_CLIENT_ID",
          clientSecret: "GOOGLE_DRIVE_CLIENT_SECRET",
          redirectUrl: "GOOGLE_DRIVE_REDIRECT_URL",
          access_token: "GOOGLE_DRIVE_ACCESS_TOKEN",
          refresh_token: "GOOGLE_DRIVE_REFRESH_TOKEN"
        }
      },
      //register the driver hanlder
      customDrivers: {
        drive: GoogleDrive
      }
    }
  }
})

Settings

| Property | Type | Description | | -------- | -----| ----------- | | STORAGE_ROOT | String | The root directory for local storage driver| | defaultStorage | String | the default driver to use, if not sepecified, local will be used | | storageConfig | Object | the configuration object, refer to Configuration object for more details |

Methods

| Name | Params | Result | Description | | ---- | ------ | ------ | ----------- | | disk | String or undefined | Storage instance| get a specifique disk storage or the default storage if no param passes. | | extends | name:String,driver: Object constructor | the StorageManager instance | extends the storage manager, the new driver configuration should have been defined in configuration. Refer to How to register custome driver |

Test

You can run npm run test to run tests

Licence

MIT