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

najm-storage

v1.1.22

Published

File storage plugin for najm framework — local filesystem and database backends

Readme

najm-storage

Storage plugin for Najm with local and database providers. Includes an optional Storage Studio admin UI (React) exposed via built-in REST routes.

Installation

bun add najm-storage

zod is a peer dependency and should be installed in the consuming app.

Core Exports

  • storage(config) plugin factory
  • StorageService, StorageValidator
  • File helpers: resolveStorageMimeType, analyzeFile, getReadableFileSize
  • Path helpers: normalizeStoragePath, isSafeStoragePath, assertSafeStoragePath
  • Upload validation: validateUploadInput
  • Schemas: storageNamespaceSchema, storagePathSchema, storageUploadSchema
  • DTO mapper: toStorageFileDto

StorageService Convenience Methods

  • getInfoOrThrow(namespace, filePath, message?)
  • deleteOrThrow(namespace, filePath, message?)
  • saveBase64(namespace, filePath, base64, mimeType?)

Storage Studio (Admin UI)

When the storage plugin is registered, a StorageStudioController is automatically mounted at /storage-studio. This provides REST endpoints consumed by the najm-storage/studio React frontend.

Studio Routes

| Route | Method | Query / Body | Description | |-------|--------|--------------|-------------| | /storage-studio/buckets | GET | — | List all namespaces | | /storage-studio/buckets/:namespace/files | GET | ?prefix=, ?delimiter=/ | List files in a namespace | | /storage-studio/buckets/:namespace/files/presign | POST | { path, method, ttlSeconds } | Generate presigned URL | | /storage-studio/:namespace/files/* | DELETE | ?hard=true | Soft delete file (fallback to hard) | | /storage-studio/trash | GET | — | List soft-deleted files across namespaces | | /storage-studio/trash/restore | POST | { namespace, path } | Restore a file from trash | | /storage-studio/usage | GET | — | Aggregated usage stats | | /storage-studio/activity | GET | — | Recent audit log entries |

Provider Capabilities

Not all providers support every Studio feature:

| Feature | Local | DB | |---------|-------|-----| | Upload / download / list | ✓ | ✓ | | Soft delete / trash | ✓ | ✓ | | Presign | ✓ (HMAC) | Falls back to direct URL | | Serve path | ✓ | ✓ |

Configuration

server.use(storage({
  provider: 'local',      // 'local' | 'db'
  basePath: './uploads',  // Local provider root directory
  dbTable: 'files',       // DB provider table name
  maxUploadSize: 10_000_000,
  allowedMimeTypes: ['image/*', 'application/pdf'],
}));

To use the React UI, import the studio from the parent package:

bun add najm-storage
import { StorageStudio, StorageStudioProvider } from 'najm-storage/studio';
import 'najm-storage/studio/styles.css';

Example

import {
  resolveStorageMimeType,
  normalizeStoragePath,
  validateUploadInput,
} from 'najm-storage';

const path = normalizeStoragePath('icons%2Flogo.png');
const mimeType = resolveStorageMimeType(undefined, path);
const result = validateUploadInput({ filePath: path, mimeType, size: 2048 });

if (!result.valid) {
  throw new Error(result.error);
}