https://github.com/emorilebo/advanced-env-manager
Secure NPM package for advanced environment variable managment for both local and server
https://github.com/emorilebo/advanced-env-manager
config dotenv env secrets security variables
Last synced: about 1 year ago
JSON representation
Secure NPM package for advanced environment variable managment for both local and server
- Host: GitHub
- URL: https://github.com/emorilebo/advanced-env-manager
- Owner: emorilebo
- License: other
- Created: 2025-02-15T21:52:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-02T15:37:57.000Z (over 1 year ago)
- Last Synced: 2025-04-04T06:18:02.052Z (about 1 year ago)
- Topics: config, dotenv, env, secrets, security, variables
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/advanced-env-manager
- Size: 163 KB
- Stars: 7
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Advanced Environment Manager
This package enhances environment variable management by adding validation, type checking, and cloud integration, making projects more secure.
## Features
- Environment variable validation with Joi schemas
- AWS Secrets Manager integration
- Environment variable encryption
- Multiple environment support
- Type checking and default values
## Installation
```sh
npm install advanced-env-manager
```
## Usage
```javascript
const EnvManager = require('advanced-env-manager');
const Joi = require('joi');
// Define your schema
const schema = Joi.object({
NODE_ENV: Joi.string().valid('development', 'production', 'test').required(),
PORT: Joi.number().default(3000),
DATABASE_URL: Joi.string().uri().required(),
});
// Initialize the manager
const envManager = new EnvManager({
encryptionKey: 'your-encryption-key',
envPath: '.env',
schema: schema,
useCloud: true // Set to true to use AWS Secrets Manager
});
// Use the manager
async function start() {
try {
const config = await envManager.initialize();
console.log('Environment configured:', config);
// Encrypt sensitive data
const encrypted = envManager.encrypt('sensitive-value');
console.log('Encrypted:', encrypted);
// Decrypt when needed
const decrypted = envManager.decrypt(encrypted);
console.log('Decrypted:', decrypted);
} catch (error) {
console.error('Configuration error:', error);
}
}
start();
```
## Testing Locally
1. Clone the repository
2. Copy `.env.example` to `.env` and fill in your values
3. Install dependencies: `npm install`
4. Run tests: `npm test`
## Environment Variables
- `NODE_ENV`: Application environment (development/production/test)
- `PORT`: Application port
- `DATABASE_URL`: Database connection string
- `ENV_ENCRYPTION_KEY`: Key for encrypting sensitive values
- `AWS_REGION`: AWS region for Secrets Manager
- `AWS_SECRET_NAME`: Name of the secret in AWS Secrets Manager
## Contributors
- Rikwu Godwin Onyung
- Ghedinaeval Charles Don-Ibor
- Michael Fredrick Ikaka
## License
ISC