@zenova-corp/key
Welcome to @zenova-corp/key! 🎉 A super handy package for managing your API keys with CockroachDB integration. Whether you want to add, update, or delete API keys, this package will make it a breeze! It even handles missing data gracefully with default values and makes sure your keys are stored securely.
🚀 Features
- Effortlessly add, update, and delete API keys.
- Default values for missing fields (
0
, false
, etc.). - Smooth integration with CockroachDB for storing your API keys.
- Works out of the box with .env configuration.
- Code structure designed with security in mind to keep things safe and sound!
💡 Installation
Ready to get started? Here’s how to install the package in your Node.js project:
-
Open your terminal and run:
npm install @zenova-corp/key
🚀 Boom! You’re all set to use it.
🛠️ Usage
Let’s jump straight into it! Below are some examples to get you going quickly. With @zenova-corp/key, you can easily manage your API keys. Whether it’s adding a new key, updating an existing one, or cleaning up old ones, it’s all at your fingertips.
Add a New API Key
const apiKeyManager = require('@zenova-corp/key');
apiKeyManager.addApiKey('new-api-key', {
expiryDate: 'unli',
remainingRequests: 1000,
maxRequests: 1000,
lastAccessDate: '2024-11-20',
});
Update an Existing API Key
apiKeyManager.updateApiKey('existing-api-key', {
remainingRequests: 500,
maxRequests: 500,
});
Delete an API Key
apiKeyManager.deleteApiKey('existing-api-key');
🔑 Methods
Here’s a breakdown of the methods available in the package:
addApiKey(apiKey, data)
: 🌟 Adds a new API key with the provided data. Pass in as much or as little as you like!updateApiKey(apiKey, data)
: 🔄 Updates an existing API key with the new details. Perfect for when you need to tweak the limits or expiration date.deleteApiKey(apiKey)
: ❌ Removes an API key from your database.
📝 Configuration
To get your package up and running, you’ll need to set up your CockroachDB configuration in a .env
file. Don’t worry, it’s quick and easy!
- Create a
.env
file in the root of your project. - Add the following values for your CockroachDB connection:
COCKROACH_DB_HOST=your-cockroachdb-host
COCKROACH_DB_PORT=26257
COCKROACH_DB_USER=your-db-user
COCKROACH_DB_PASSWORD=your-db-password
COCKROACH_DB_NAME=your-db-name
Once you’ve done that, your API key management is ready to go! 🎉
🎉 License
This package is licensed under the MIT License. Check out the full details in the LICENSE file.
🤝 Contributing
Got an idea or want to improve things? Pull requests and issues are always welcome! 😄 If you want to contribute, just fork this repo, make your changes, and submit a pull request. Let’s make this package even better together! 🎨
✨ Enjoy using @zenova-corp/key to manage your API keys easily and securely! 🚀