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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@edirect/storage-gateway

v11.0.36

Published

Storage Gateway client library for eDirect applications. Provides a simple interface to interact with the Storage Gateway API for managing storage configurations and file operations.

Readme

@edirect/storage-gateway

Storage Gateway client library for eDirect applications. Provides a simple interface to interact with the Storage Gateway API for managing storage configurations and file operations.

Installation

npm install @edirect/storage-gateway

Quick Start

import { StorageGatewayClient } from '@edirect/storage-gateway';

// Create client without headers
const client = new StorageGatewayClient('https://api.example.com');

// Or with authentication headers
const client = new StorageGatewayClient('https://api.example.com', {
  authorization: 'Bearer your-token-here',
});

// List storage configurations
const configs = await client.listStorageConfigurations();

// Upload a file
const file = new File(['content'], 'example.txt');
const result = await client.uploadFile({
  storageKey: 'my-storage',
  file: file,
  path: 'documents/example.txt',
});

API Reference

Constructor

new StorageGatewayClient(baseUrl: string, headers?: StorageGatewayHeaders)

Parameters:

  • baseUrl - The base URL of the Storage Gateway API
  • headers (optional) - Headers to include in all requests

Types:

interface StorageGatewayHeaders {
  authorization: string;
  [key: string]: string;
}

Storage Configuration Methods

listStorageConfigurations

List all storage configurations with optional pagination.

const configs = await client.listStorageConfigurations();

// With pagination
const configs = await client.listStorageConfigurations({
  skip: 0,
  take: 10,
});

Parameters:

  • params.skip (optional) - Number of records to skip
  • params.take (optional) - Number of records to return

createStorageConfiguration

Create a new storage configuration.

const config = await client.createStorageConfiguration({
  key: 'my-storage',
  provider: 's3',
  credentials: {
    accessKeyId: 'your-access-key',
    secretAccessKey: 'your-secret-key',
    region: 'us-east-1',
    bucket: 'my-bucket',
  },
});

Parameters:

  • data - Configuration data object

getStorageConfiguration

Get a specific storage configuration by key.

const config = await client.getStorageConfiguration('my-storage');

Parameters:

  • key - The storage configuration key

updateStorageConfiguration

Update an existing storage configuration.

const updated = await client.updateStorageConfiguration({
  key: 'my-storage',
  data: {
    credentials: {
      accessKeyId: 'new-access-key',
      secretAccessKey: 'new-secret-key',
    },
  },
});

Parameters:

  • params.key - The storage configuration key
  • params.data - Updated configuration data

deleteStorageConfiguration

Delete a storage configuration.

await client.deleteStorageConfiguration('my-storage');

Parameters:

  • key - The storage configuration key to delete

Storage Operations Methods

listFiles

List files in storage.

const files = await client.listFiles({
  storageKey: 'my-storage',
});

// With path filter
const files = await client.listFiles({
  storageKey: 'my-storage',
  path: 'documents/',
});

Parameters:

  • params.storageKey - The storage configuration key
  • params.path (optional) - Path to list files from

uploadFile

Upload a file to storage.

const file = new File(['Hello, World!'], 'hello.txt', { type: 'text/plain' });

const result = await client.uploadFile({
  storageKey: 'my-storage',
  file: file,
  path: 'documents/hello.txt',
});

Parameters:

  • params.storageKey - The storage configuration key
  • params.file - The file to upload (File or Blob)
  • params.path (optional) - Destination path for the file

downloadFile

Download a file from storage.

const blob = await client.downloadFile({
  storageKey: 'my-storage',
  path: 'documents/hello.txt',
});

// Save to file (Node.js)
const buffer = await blob.arrayBuffer();
fs.writeFileSync('downloaded.txt', Buffer.from(buffer));

// Or create download link (Browser)
const url = URL.createObjectURL(blob);

Parameters:

  • params.storageKey - The storage configuration key
  • params.path - Path to the file to download

Returns: Promise<Blob>


getFileInfo

Get file metadata information.

const info = await client.getFileInfo({
  storageKey: 'my-storage',
  path: 'documents/hello.txt',
});

console.log(info);
// { name: 'hello.txt', size: 1024, lastModified: '2024-01-01T00:00:00Z', ... }

Parameters:

  • params.storageKey - The storage configuration key
  • params.path - Path to the file

deleteFile

Delete a file from storage.

await client.deleteFile({
  storageKey: 'my-storage',
  path: 'documents/hello.txt',
});

Parameters:

  • params.storageKey - The storage configuration key
  • params.path - Path to the file to delete

Storage Provider Methods

listStorageProviders

List available storage providers.

const providers = await client.listStorageProviders();

console.log(providers);
// ['s3', 'azure-blob', 'gcs', 'local', ...]

Complete Example

import { StorageGatewayClient } from '@edirect/storage-gateway';

async function main() {
  // Initialize client
  const client = new StorageGatewayClient('https://storage-gateway.example.com', {
    authorization: 'Bearer your-jwt-token',
  });

  // List available providers
  const providers = await client.listStorageProviders();
  console.log('Available providers:', providers);

  // Create a new storage configuration
  const config = await client.createStorageConfiguration({
    key: 'documents-storage',
    provider: 's3',
    credentials: {
      accessKeyId: process.env.AWS_ACCESS_KEY_ID,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
      region: 'us-east-1',
      bucket: 'my-documents-bucket',
    },
  });
  console.log('Created config:', config);

  // Upload a file
  const file = new File(['Hello, World!'], 'hello.txt', { type: 'text/plain' });
  const uploadResult = await client.uploadFile({
    storageKey: 'documents-storage',
    file: file,
    path: 'greetings/hello.txt',
  });
  console.log('Upload result:', uploadResult);

  // List files
  const files = await client.listFiles({
    storageKey: 'documents-storage',
    path: 'greetings/',
  });
  console.log('Files:', files);

  // Get file info
  const fileInfo = await client.getFileInfo({
    storageKey: 'documents-storage',
    path: 'greetings/hello.txt',
  });
  console.log('File info:', fileInfo);

  // Download file
  const blob = await client.downloadFile({
    storageKey: 'documents-storage',
    path: 'greetings/hello.txt',
  });
  const text = await blob.text();
  console.log('Downloaded content:', text);

  // Delete file
  await client.deleteFile({
    storageKey: 'documents-storage',
    path: 'greetings/hello.txt',
  });
  console.log('File deleted');

  // Delete storage configuration
  await client.deleteStorageConfiguration('documents-storage');
  console.log('Configuration deleted');
}

main().catch(console.error);

License

MIT