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

@uddisharma/store-keeper

v1.0.2

Published

Store Keeper === A flexible and feature-rich storage package that supports multiple storage adapters (local, S3, GCS), encryption, and schema validation.

Downloads

3

Readme

Store Keeper

A flexible and feature-rich storage package that supports multiple storage adapters (local, S3, GCS), encryption, and schema validation.

Features

  • Multiple Storage Adapters: Local filesystem, AWS S3, Google Cloud Storage
  • Data Encryption: Encrypt and decrypt data before storing and retrieving
  • Schema Validation: Validate data against a defined schema before storage

Install & Dependence

Install the package via npm:

npm install @uddisharma/store-keeper

Configuration

Create a config.ts file to manage your configuration settings.

// config.ts
export const localConfig = {
  storagePath: './local-storage',
};

export const s3Config = {
  bucketName: 'your-s3-bucket',
  region: 'your-region',
  accessKeyId: 'your-access-key-id',
  secretAccessKey: 'your-secret-access-key',
};

export const gcsConfig = {
  bucketName: 'your-gcs-bucket',
  projectId: 'your-project-id',
  clientEmail: 'your-client-email',
  privateKey: 'your-private-key',
};

Usage

Initializing the Storage

import Storage from '@uddisharma/store-keeper';
import { localConfig, s3Config, gcsConfig } from './config';

const encryptionKey = 'your-encryption-key';

// For local storage
const localStorage = new Storage('local', localConfig, encryptionKey);

// For AWS S3 storage
const s3Storage = new Storage('s3', s3Config, encryptionKey);

// For Google Cloud Storage
const gcsStorage = new Storage('gcs', gcsConfig, encryptionKey);

Storing Data

const filename = 'data.json';
const data = { name: 'John Doe', age: 30 };

await localStorage.storeData(filename, data);
await s3Storage.storeData(filename, data);
await gcsStorage.storeData(filename, data);

Retrieving Data

const retrievedDataLocal = await localStorage.retrieveData(filename);
const retrievedDataS3 = await s3Storage.retrieveData(filename);
const retrievedDataGCS = await gcsStorage.retrieveData(filename);

console.log(retrievedDataLocal); // { name: 'John Doe', age: 30 }
console.log(retrievedDataS3); // { name: 'John Doe', age: 30 }
console.log(retrievedDataGCS); // { name: 'John Doe', age: 30 }

Updating Data

const updatedData = { age: 31 };

await localStorage.updateData(filename, updatedData);
await s3Storage.updateData(filename, updatedData);
await gcsStorage.updateData(filename, updatedData);

Deleting Data

await localStorage.deleteData(filename);
await s3Storage.deleteData(filename);
await gcsStorage.deleteData(filename);

Storage Adapters

The storage package provides multiple storage adapters, allowing you to choose the appropriate storage backend based on your needs.

  • Local Adapter: Stores data on the local filesystem.
  • AWS S3 Adapter: Stores data in an AWS S3 bucket.
  • Google Cloud Storage Adapter: Stores data in a Google Cloud Storage bucket.

Data Encryption

Data encryption is crucial for protecting sensitive information. The storage package uses AES-256-CTR for encryption and decryption, ensuring your data is secure.

Schema Validation

Schema validation ensures that the data being stored meets the predefined structure. This package uses Joi for schema validation, making it easy to enforce data integrity.

Example

Here’s a full example demonstrating how to use the storage package.

import Storage from '@uddisharma/store-keeper';
import { localConfig } from './config';

const encryptionKey = 'your-encryption-key';
const storage = new Storage('local', localConfig, encryptionKey);

const filename = 'user-data.json';
const userData = {
  name: 'Alice',
  email: '[email protected]',
  age: 25,
};

// Storing data
await storage.storeData(filename, userData);

// Retrieving data
const retrievedData = await storage.retrieveData(filename);
console.log(retrievedData); // { name: 'Alice', email: '[email protected]', age: 25 }

// Updating data
const updatedData = { age: 26 };
await storage.updateData(filename, updatedData);

// Deleting data
await storage.deleteData(filename);

License

This README.md file provides a detailed overview of the storage package, including installation instructions, configuration, and usage examples for different storage adapters. It also explains the theory behind the package, making it easier for users to understand its functionality and purpose.

Author