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 🙏

© 2026 – Pkg Stats / Ryan Hefner

uplix

v2.0.7

Published

image, files & media handler (images, video, audio, docs) with auto-processing

Readme

uplix

MediaManager.js

A Node.js media management utility & media handling.
Supports single & multiple file uploads, any file type, image resizing & conversion, and controller-level usage (no middleware needed). get usage in example folder

📦 Installation

    npm install uplix

    # Usage direct in controller
    const { MediaManager } = require('uplix');

    const media = new MediaManager(
    'uploads',
    '/uploads',
    { maxFileSizeMB: 10 },
    { convertToWebP: true } # false for original extension
    );

  # Create fields and files

  # Parse fields and files automatically
  const payload = await media.auto(req);
  # Handle image upload
  let imageFileName = null;
  if (payload.image) {
    const fileData = Array.isArray(payload.image) ? payload.image[0] : payload.image;
    imageFileName = fileData.fileName;
  }

  # Create new model
  const model = await Model.create({
    name: payload.name,
    image: imageFileName,
    is_active: payload.is_active ?? false, # boolean parsed by auto()
  });


    # Update fields and files

    const model = await Model.find(req.params.id);
    # Auto-parse fields and files
    const data = await media.auto(req);
    # Fill other fields
    model.fill({
        name: data.name,
        is_active: model.is_active ?? false, # already boolean from auto()
    });
    # Handle image upload
    if (data.image) {
        # Normalize: payload.image may be an array if multiple files uploaded
        const fileData = Array.isArray(data.image) ? data.image[0] : data.image;
        # Remove old file if it exists
        if (model.image) {
        await media.remove(model.image, 'image');
        }
        # Update with new file
        model.image = fileData.fileName;
    }
    await model.save();

    # Delet files
    if (model.image) {
        await media.remove(model.image, 'image');
    }
    

    # SECOND METHOD

    # Create file
    let image;
    image = await media.file(req, 'image', {
        resize: true,
        width: 1920,
        height: 1080,
        format: 'webp',
        quality: 80
    });
    await Model.create({
    image: image.fileName
    });


    # Update file  
    const { files } = await media.parseRequest(req);
    const model = await Model.find(req.params.id);
    let imageName = model.image;
    # ✅ DYNAMIC: works for single or multiple
    if (media.hasFile(files, 'image')) {
    const imageFile = media.getFirstFile(files, 'image');
    const image = await media.processFile(imageFile, 'image', {
        resize: true,
        width: 1920,
        height: 1080,
        format: 'webp',
        quality: 80
    });
    # Remove old image safely
    if (model.image) {
        await media.remove(model.image, 'image');
    }
    imageName = image.fileName;
    }
    await model.update({
    image: imageName
    });


    # Controller Example Usage With Different File Types
    const media = new MediaManager('./uploads/files', '/uploads/files');

    # Upload a PDF
    const pdfFile = await media.file(req, 'document'); 

    # Upload multiple videos
    const videos = await media.files(req, 'videos');

    # Upload an MP3
    const song = await media.file(req, 'song');
    
    #Uploads one required file.
    const avatar = await media.file(req, 'avatar');
    <input type="file" name="avatar">

    #BONUS: MULTIPLE FILES (Gallery Example)
    const gallery = await media.files(req, 'gallery');
    <input type="file" name="gallery" multiple>

    # Automatically decides single vs multiple
    const data = await media.auto(req);
    # Example form
    <input type="text" name="title">
    <input type="file" name="thumbnail">
    <input type="file" name="gallery" multiple>


    const uploaded = await Promise.all(
    galleryFiles
        .filter(f => f.size > 0)
        .map(f => media.processFile(f, 'gallery'))
    );
    # Supported image formats
    jpg, jpeg, png, webp, tiff, gif

    # Enable WebP conversion
    new MediaManager('uploads', '/uploads', {}, {
      convertToWebP: true
    });

    # Returned metadata
    {
    id: "e8c7a...",
    field: "avatar",
    fileName: "1699-abc.webp",
    mime: "image/webp",
    sizeMB: 0.43,
    path: "/uploads/avatar/1699-abc.webp",
    url: "/uploads/avatar/1699-abc.webp",
    createdAt: Date
    }