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

mv-s3-manager-core

v0.0.1

Published

Framework-agnostic S3-compatible bucket management

Downloads

109

Readme

mv-s3-manager/core

Gestione bucket S3-compatibili indipendente dal framework per Node.js.

Funziona con AWS S3, MinIO, Cloudflare R2, Backblaze B2 e qualsiasi provider S3-compatibile.

Installazione

npm install mv-s3-manager/core @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
# oppure
pnpm add mv-s3-manager/core @aws-sdk/client-s3 @aws-sdk/s3-request-presigner

Avvio rapido

import { createClient, uploadObject, downloadObjectAsBuffer } from "mv-s3-manager/core";
import type { S3ManagerConfig } from "mv-s3-manager/core";

const config: S3ManagerConfig = {
  region: "us-east-1",
  credentials: {
    accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
  },
  bucket: "mio-bucket",
};

const client = createClient(config);

// Upload
await uploadObject(client, config, "ciao.txt", "Ciao, mondo!", {
  contentType: "text/plain",
});

// Download
const buffer = await downloadObjectAsBuffer(client, config, "ciao.txt");
console.log(buffer.toString("utf-8")); // "Ciao, mondo!"

Configurazione

| Campo | Tipo | Obbligatorio | Descrizione | |---|---|---|---| | region | string | ✅ | Regione AWS o del provider (es. "auto" per Cloudflare R2) | | credentials.accessKeyId | string | ✅ | Access key ID | | credentials.secretAccessKey | string | ✅ | Secret access key | | bucket | string | ✅ | Nome del bucket di destinazione | | endpoint | string | — | URL endpoint personalizzato per provider non-AWS | | forcePathStyle | boolean | — | Obbligatorio per MinIO e Ceph. Default: false |

MinIO

const config: S3ManagerConfig = {
  endpoint: "http://localhost:9000",
  region: "us-east-1",
  credentials: { accessKeyId: "minioadmin", secretAccessKey: "minioadmin" },
  bucket: "mio-bucket",
  forcePathStyle: true,
};

Cloudflare R2

const config: S3ManagerConfig = {
  endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
  region: "auto",
  credentials: { accessKeyId: R2_ACCESS_KEY, secretAccessKey: R2_SECRET_KEY },
  bucket: "mio-bucket",
};

Riferimento API

createClient(config)

Crea un S3Client configurato. Riutilizzalo tra le richieste — l'SDK gestisce il connection pooling.

validateConfig(config)

Verifica a runtime che config sia una S3ManagerConfig valida. Lancia S3ManagerConfigError in caso di errore. Da chiamare una volta all'avvio.

uploadObject(client, config, key, body, options?)

| Parametro | Tipo | Descrizione | |---|---|---| | key | string | Chiave dell'oggetto (percorso nel bucket) | | body | Uint8Array \| ReadableStream \| string | Contenuto da caricare | | options.contentType | string | Tipo MIME. Default: "application/octet-stream" | | options.metadata | Record<string, string> | Metadati chiave-valore | | options.storageClass | string | Override della classe di storage |

Restituisce UploadResult: { key, etag, url }.

downloadObject(client, config, key)

Restituisce DownloadResult: { body: Readable, contentType, contentLength, metadata, etag }.

Lancia S3ManagerNotFoundError se la chiave non esiste.

downloadObjectAsBuffer(client, config, key)

Wrapper di convenienza che bufferizza l'intero oggetto in memoria. Sconsigliato per file di grandi dimensioni.

deleteObject(client, config, key)

Idempotente. Non lancia errori se la chiave non esiste.

deleteObjects(client, config, keys)

Eliminazione batch fino a 1000 chiavi per chiamata (le liste più grandi vengono divise automaticamente). Restituisce un array delle chiavi fallite.

listObjects(client, config, options?)

| Opzione | Tipo | Descrizione | |---|---|---| | prefix | string | Filtra per prefisso della chiave | | maxKeys | number | Numero massimo di risultati per pagina | | continuationToken | string | Token di paginazione dal risultato precedente |

Restituisce ListResult: { objects: S3Object[], nextContinuationToken, isTruncated }.

listAllObjects(client, config, options?)

Generatore asincrono che pagina automaticamente. Produce un S3Object alla volta.

for await (const obj of listAllObjects(client, config, { prefix: "log/" })) {
  console.log(obj.key, obj.size);
}

getPresignedDownloadUrl(client, config, key, options?)

Genera un URL GET a tempo limitato. Scadenza predefinita: 3600 secondi.

getPresignedUploadUrl(client, config, key, options?)

Genera un URL PUT a tempo limitato per l'upload diretto lato client.

Tipi di errore

| Classe | Quando viene lanciata | |---|---| | S3ManagerConfigError | Configurazione non valida | | S3ManagerNotFoundError | La chiave oggetto non esiste | | S3ManagerUploadError | Upload fallito | | S3ManagerDeleteError | Eliminazione fallita | | S3ManagerListError | Listaggio fallito | | S3ManagerPresignError | Generazione URL prefirmato fallita |

Tutte estendono S3ManagerError (che estende Error) e portano un campo cause.