openratul
v1.3.2
Published
Drop-in replacement for dotenv. Load env from Convex.
Readme
OpenRatul
Drop-in replacement for dotenv. Store environment variables in Convex, fetch them at runtime.
Why?
- Security — No sensitive env vars in local
.envfiles - Centralized — All envs in one place (Convex Dashboard)
- Secure — Vars only exist in memory during script runtime
- Drop-in — Replace
import "dotenv/config"withimport "openratul"
Installation
npm install openratulUsage
Replace in your existing script:
// Before
import "dotenv/config";
// After
import "openratul";Or for CommonJS:
// Before
require("dotenv").config();
// After
require("openratul").default.config();That's it! Your process.env.* vars are now loaded from Convex.
Setup
1. Convex Dashboard
Add environment variables starting with ENV_:
| Variable | Example |
|---|---|
| ENV_API_KEY | your-api-key |
| ENV_SECRET | your-secret |
| ENV_DB_URL | postgres://... |
2. Local .env
Only need OPENRATUL_URL:
OPENRATUL_URL=https://your-deployment.convex.site3. Run your script
node your-script.js- On startup → requests admin approval → fetches
ENV_*vars - On exit → clears all fetched vars from memory
How It Works
Script Convex You
│ │ │
│── POST /request-access ─▶│ │
│◀─ { requestId } ─────────│ │
│ │──── Telegram ─────────▶ (approve)
│── GET /poll ────────────▶│ │
│◀─ { status: "approved" }│ │
│ │ │
│── GET /env ──────────────▶│ │
│◀─ { ENV_API_KEY: "..." } │ │API
import { init, fetchEnv, clearEnv, getEnv } from "openratul";
await init(); // Auto-initializes on import
await fetchEnv(); // Force fetch env
clearEnv(); // Clear env vars from memory
const env = getEnv(); // Get cached envDemo
# Clone and try
git clone https://github.com/your-repo/openratul.git
cd openratul
# Add ENV_* vars in Convex Dashboard
# Set OPENRATUL_URL in .env
node examples/basic.jsLicense
MIT
