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

metaserve-core

v1.0.2

Published

A fast, secure metadata extractor for static files with plugin support for images, audio, PDFs, and more.

Readme

MetaServe-Core

High-performance metadata extractor for static file servers. Plugin-based. Zero dependencies on the core. Safe by default.

Why this solves an actual problem

Most servers expose static files but can’t tell you anything about those files without reading the whole file or building a custom parser. Browsers also can't read file stats or metadata for files on the server side.

Typical problems MetaServe solves:

  • Need to know the image width/height without loading the image in frontend.
  • Need to find heavy assets inside a project.
  • Need metadata for different file types without writing a unique parser for each.
  • Need server-side metadata checks before UI rendering or build systems.
  • Need a single API that returns consistent metadata for any file.

Every frontend framework and SSR system benefits from this capability.

MetaServe is the clean solution they never bothered to make.


Installation

npm install metaserve-core

Basic Usage

Server setup (Express example)

const express = require('express');
const MetaServe = require('metaserve-core');
const imageParser = require('metaserve-core/plugins/ImageParser');

const app = express();
const metaServe = new MetaServe({ debug: true });

// Register image plugin
['.jpg', '.jpeg', '.png', '.gif', '.webp'].forEach(ext =>
  metaServe.register(ext, imageParser)
);

app.use(express.static('public'));

app.use((req, res, next) => {
  const handled = metaServe.getHandler('public')(req, res);
  if (!handled) next();
});

app.listen(3000);

Metadata Query Format

To get metadata of /public/photo.jpg:

/photo.jpg?meta=1

Response example:

{
  "size": 12345,
  "created": "2025-11-29T04:12:19.000Z",
  "modified": "2025-11-29T04:12:19.000Z",
  "type": ".jpg",
  "width": 1920,
  "height": 1080,
  "format": "jpg",
}

Features

  • Ultra-fast stat-based metadata for all files
  • Safe path traversal protection
  • Max-size limit to avoid expensive parser operations
  • Plugin architecture for any file type
  • Timeout protection for buggy plugins
  • Zero heavy dependencies in core

Writing a Plugin

A plugin is a simple async function that returns extra metadata.

module.exports = async function(filePath) {
  return {
    customData: "any value"
  };
};

Register it:

metaServe.register('.txt', myParser);

Built-in Plugins

(metaServe-core never forces plugins; below is optional)

Image Parser

Use the official MetaServe image plugin:

const imageParser = require('metaserve-image');
metaServe.register('.png', imageParser);

Security & Limitations

  • Rejects symlink traversal
  • Rejects requests outside the root
  • Rejects files above 200MB (configurable)
  • Rejects slow parsers via timeout

Examples Folder

  • Express

const express = require('express');
const path = require('path');
const MetaServe = require('metaserve-core');
const imageParser = require('metaserve-core/plugins/ImageParser');

const app = express();
const publicDir = path.join(__dirname, 'public');

const metaServe = new MetaServe({
  debug: true,
  timeout: 2000
});

// Register image plugins
['.jpg', '.jpeg', '.png', '.gif', '.webp'].forEach(ext =>
  metaServe.register(ext, imageParser)
);

const metaHandler = metaServe.getHandler(publicDir);

app.use((req, res, next) =>
  metaHandler(req, res).then(handled => handled || next())
);

app.use(express.static(publicDir));

app.listen(3000, () => {
  console.log('Server running at http://localhost:3000');
});




Contributing

  • Open issues for new parsers (PDF, audio, etc.)
  • PRs welcome
  • Keep plugins optional and core clean