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

@jembi/openhim-datalake-lib

v1.0.0

Published

Reusable datalake (MinIO/S3) upload and bucket management for OpenHIM mediators

Readme

@jembi/openhim-datalake-lib

Reusable datalake (MinIO/S3) upload and bucket management library for OpenHIM mediators.

Features

  • Upload Service: Upload files from buffers or paths with automatic metadata handling
  • Download Service: Download files to buffers or paths, with presigned URL support
  • Bucket Management: Create, validate, and manage buckets
  • Listener Manager: Plugin-based file processing with bucket notifications
  • OpenHIM Integration: Automatic mediator registration and bucket config sync
  • Event System: Cross-mediator communication via typed events

Installation

npm install @jembi/openhim-datalake-lib minio openhim-mediator-utils

Quick Start

import { createDatalakeLib } from "@jembi/openhim-datalake-lib";

const lib = createDatalakeLib({
  datalake: {
    endPoint: "localhost",
    port: 9000,
    useSSL: false,
    accessKey: "your-access-key",
    secretKey: "your-secret-key",
  },
  openhim: {
    apiURL: "https://localhost:8080",
    username: "[email protected]",
    password: "password",
    mediatorUrn: "urn:mediator:my-mediator",
  },
});

// Upload a file
const result = await lib.upload.uploadBuffer(
  fileBuffer,
  "data.json",
  "application/json",
  { bucket: "my-bucket", createBucketIfNotExists: true },
);

// Download a file to buffer
const download = await lib.download.downloadToBuffer("my-bucket", "data.json");
if (download.success) {
  console.log("Downloaded:", download.buffer?.toString());
}

// Download a file to disk
await lib.download.downloadToPath("my-bucket", "data.json", "/tmp/data.json");

// Get a presigned URL (valid for 1 hour)
const url = await lib.download.getPresignedUrl("my-bucket", "data.json", 3600);

File Processing Plugins

Register processors to handle specific file types:

lib.listeners.registerProcessor({
  canProcess: (file, mimeType) => mimeType === "application/json",
  process: async (ctx) => {
    const data = JSON.parse(ctx.buffer.toString());
    // Process the data...
  },
});

// Start listening for bucket notifications
await lib.listeners.startListening(["my-bucket"]);

Cross-Mediator Events

Listen for events from other mediators:

import { mediatorEvents } from "@jembi/openhim-datalake-lib";

mediatorEvents.onUpload((event) => {
  console.log(`File ${event.file} uploaded to ${event.bucket}`);
});

API Reference

createDatalakeLib(config)

Creates a configured library instance. Returns:

| Property | Type | Description | | ----------- | ---------------------- | ------------------------ | | client | Minio.Client | Underlying MinIO client | | upload | UploadService | File upload operations | | download | DownloadService | File download operations | | buckets | BucketManager | Bucket management | | listeners | ListenerManager | Notification listeners | | openhim | OpenHIMService? | OpenHIM integration | | events | MediatorEventEmitter | Event emitter |

UploadService

  • uploadBuffer(buffer, fileName, mimeType, options) - Upload from buffer
  • uploadFromPath(path, fileName, mimeType, options) - Upload from file path

DownloadService

  • downloadToBuffer(bucket, fileName) - Download file as Buffer
  • downloadToPath(bucket, fileName, destPath) - Download file to local path
  • getPresignedUrl(bucket, fileName, expirySeconds?) - Get presigned download URL

BucketManager

  • ensureExists(bucket, createIfNotExists?) - Ensure bucket exists
  • checkFileExists(bucket, fileName) - Check if file exists
  • BucketManager.validateName(name) - Validate bucket name
  • BucketManager.sanitizeName(name) - Sanitize to valid name

ListenerManager

  • registerProcessor(processor) - Register file processor
  • startListening(buckets) - Start listening for notifications
  • stopListening() - Stop all listeners

License

Apache-2.0