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

safekeys

v0.1.0

Published

A secure and flexible tool for managing sensitive configuration data in Node.js applications

Downloads

13

Readme

SafeKeys

SafeKeys is a secure and flexible tool for managing sensitive configuration data in Node.js applications. It offers advanced features for secure key management, environment-specific configurations, and error handling, making it ideal for managing secrets in your projects.

Features

  • Secure Key Management: Safely store and retrieve sensitive data like API keys and passwords.
  • Environment-Specific Configurations: Automatically load environment-based configuration files.
  • Advanced Error Handling: Comprehensive error codes and messages for troubleshooting.
  • Dynamic Key Validation: Validate key-value pairs with custom rules.
  • Hot Reloading: Support for hot reloading of configuration files.

Installation

npm install safekeys

Usage

Initializing SafeKeys

For TypeScript projects:

import sks from 'safekeys';

sks.init().then(() => {
  if (sks.has('API_KEY')) {
    console.log('API Key:', sks.get('API_KEY'));
  }
});

For JavaScript projects:

const sks = require('safekeys');

sks.init().then(() => {
  if (sks.has('API_KEY')) {
    console.log('API Key:', sks.get('API_KEY'));
  }
});

Or initialize directly:

require('safekeys').init();
// Your code...

Error Handling

import SKSError from 'safekeys/SKSError';

try {
  // Your logic here
} catch (err) {
  if (err instanceof SKSError) {
    console.error('SafeKeys Error:', err.message);
  }
}

Configuration File (.sks)

SafeKeys uses a .sks file for storing key-value pairs. The format is simple:

API_KEY=your-api-key-here
DATABASE_URL=your-database-url-here

Adding Values

The add function allows you to add values to arrays or key-value pairs to objects within the .sks file.

  • For Arrays: If the specified key refers to an array, you can add new items to it.
  • For Objects: If the specified key refers to an object, you can add or update key-value pairs within it.

Example Usage

// Adding to an array
sks.add('arrayKey', 'newItem');

// Adding key-value pair to an object
sks.add('objectKey', 'newSubKey', 'newValue');

License

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

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.

Acknowledgements

Thanks to all contributors and the open-source community for making this project possible.