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

storage-server

v1.2.0

Published

File server with multiple storage backends

Readme

File Storage Server

A distributed file storage system built with NestJS that provides high availability and multi-storage backend support with automatic failover capabilities.

📋 Project Overview

This project is a robust file storage microservice designed for enterprise applications requiring reliable file management across multiple storage backends. It acts as an abstraction layer between your application and various storage systems (MinIO, FTP, local filesystem), providing unified APIs for file operations while ensuring high availability through intelligent failover mechanisms.

Key Use Cases:

  • Hospital/Healthcare systems managing medical images and documents
  • Multi-tenant applications requiring isolated storage buckets
  • Systems requiring automatic failover for critical file storage
  • Applications needing dynamic image resizing for web/mobile delivery
  • Content delivery with format optimization (WebP, AVIF conversion)

⚡ Key Features

  • Multi-Storage Support: Support for MinIO, FTP (FileZilla), and other storage systems
  • High Availability: Automatic server failover when issues occur
  • File Streaming: Support for video/audio streaming
  • Image Processing: On-the-fly image resizing and format conversion
  • Priority System: Configurable server priority system
  • RESTful API: Complete API for upload, download, stream, and delete operations
  • Swagger Documentation: Auto-generated API documentation

🗄 Database Schema

server Table

- id: Primary key
- server_name: Server name
- key_server: Server cluster identifier
- read_priority: Priority order (1 = highest)
- type_server: enum('minio', 'filezilla')
- config: JSON configuration for server connection
- is_active: Server active status

data_path Table

- id: Primary key
- path: File path
- key_server: Foreign key to server
- original_filename: Original filename
- mime_type: File MIME type
- file_size: File size in bytes

📚 API Documentation

Access Swagger documentation after starting the server: {server}/api/docs

Main APIs:

File Operations

  • POST /api/files/upload - Upload file with buffer
  • GET /api/files/:id - Get file with optional image resize
    • Query params: width, height, fit (cover|contain|fill|inside|outside), format (jpeg|png|webp|avif)
  • GET /api/files/buffer/:id - Get file buffer (base64) with optional resize
  • GET /api/files/info/* - Get file information
  • DELETE /api/files/:path - Delete file

Image Resize Examples:

GET /api/files/123?width=300&height=200&fit=cover
GET /api/files/123?width=500&format=webp
GET /api/files/buffer/123?width=800&height=600&format=jpeg

Server Management

  • GET /api/servers - List all servers
  • GET /api/servers/active - List active servers
  • POST /api/servers/health-check/:keyServer - Check server health
  • POST /api/servers/switch-priority - Switch server priority

🔧 Storage Configuration

MinIO

{
  "endpoint": "localhost",
  "port": 9000,
  "accessKey": "minioadmin",
  "secretKey": "minioadmin",
  "useSSL": false,
  "bucketName": "file-storage"
}

FTP (FileZilla)

{
  "host": "localhost",
  "port": 21,
  "user": "ftpuser",
  "password": "ftppass"
}

🛡 High Availability

The system automatically:

  1. Uses servers with read_priority = 1 and is_active = true
  2. Automatically switches to the next priority server when the primary fails
  3. Provides manual failover via the switch-priority API

🖼 Image Processing

Built-in image processing capabilities using Sharp:

  • Resize: Specify width and/or height
  • Fit modes: cover, contain, fill, inside, outside
  • Format conversion: JPEG, PNG, WebP, AVIF
  • Quality control: Optimized compression settings
  • Automatic detection: Only processes image MIME types

🔍 Monitoring

  • Health check endpoints for each server
  • Detailed logs for debugging
  • Swagger UI for API testing

📝 Development

# Install dependencies
npm install

# Watch mode
npm run start:dev

# Run tests
npm run test

# Build for production
npm run build

# Run production
npm run start:prod

📦 Dependencies

  • NestJS - Backend framework
  • Sharp - Image processing
  • MinIO Client - Object storage
  • FTP - File transfer protocol
  • TypeORM - Database ORM
  • Swagger - API documentation