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 🙏

© 2024 – Pkg Stats / Ryan Hefner

obj-kvs

v1.0.2

Published

Store objects in the cloud or locally

Downloads

210

Readme

obj-kvs

This Object Storage Library provides a flexible and extensible way to manage data across different storage backends. It includes support for in-memory storage, flat file storage, and Amazon S3 storage. The API abstracts storage details, allowing for easy switching between backends and handling optional compression based on metadata.

Features

  • Multiple Storage Engines: Supports InMemory, FlatFile, and S3 engines.
  • Compression: Optional gzip compression for stored data based on metadata settings.
  • Flexible Key Management: Optional key handling with default keys if not provided.
  • Unified API: A single API interface for all storage operations across different engines.

Storage Engines

InMemory Engine

  • Fast access: Stores data in the RAM of the server, providing fast access and manipulation.
  • Volatile: Data is lost when the process exits, suitable for caching temporary data.
  • TTL Support: Optional time-to-live for automatic data expiration.

FlatFile Engine

  • Persistence: Stores data in the file system, providing persistence across server restarts.
  • Directory Structure: Uses a structured directory path of basePath > namespace > id > objects for storage.
  • JSON Storage: Data and metadata are stored as JSON files, base64-encoded for binary data.

S3 Engine

  • Scalable: Leverages Amazon S3 for scalable and robust cloud storage.
  • Region and ACL Support: Configurable AWS region and access control list settings.
  • Metadata Handling: Stores custom metadata including MIME type, gzip status, and TTL.

Installation

To use this library, clone the repository and install necessary dependencies:

git clone <repository-url>
cd object-storage-library
npm install

Appender and ObjectStorage APIs

This repository contains two Node.js APIs: the ObjectStorage API and the Appender API. The ObjectStorage API provides a generic interface for storing objects using various backends (In Memory, Flat File, S3), while the Appender API is designed to manage append-only storage scenarios, ideal for managing versioned data or logs.

Features

  • ObjectStorage API: Supports multiple storage backends and operations like get, put, delete, and scan.
  • Appender API: Built on top of the ObjectStorage API, it handles append operations, maintaining a pointer to the latest version of each object.

Installation

Clone this repository and install dependencies:

git clone <repository-url>
cd your-repo-directory
npm install

Usage

ObjectStorage API

const { newInMemoryStorageController, newFlatFileStorageController, newS3StorageController } = require('obj-kvs');

// Initialize the storage API with an InMemory engine
const storage = newInMemoryStorageController();

// Example operations
storage.put('namespace', 'id', 'key', Buffer.from('data'), { gzip: true, mimeType:"text/plain" });
storage.get('namespace', 'id', 'key').then(console.log);
storage.delete('namespace', 'id', 'key');

Appender API

const { newInMemoryAppenderController, newFlatFileAppenderController, newSAppenderController } = require('obj-kvs');

const appender = newInMemoryAppenderController();

// Append a new version of an object
appender.append('namespace', 'id', '2023-04-01', Buffer.from('new data'), {mimeType:"text/plain"});

// Get the latest version
appender.getLatest('namespace', 'id').then(console.log);

// Scan for all versions
appender.scan('namespace', 'id').then(console.log);

Contributing

Contributions are welcome! Please fork this repository and submit pull requests with your enhancements or open issues for any bugs or new features you suggest.

License

This project is licensed under the MIT License - see the LICENSE file for details.