UNPKG

@envkit/nextjs

Version:

Environment variable management for Next.js applications

55 lines 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EnvKit = void 0; exports.createEnvKit = createEnvKit; const schema_1 = require("./schema"); /** * EnvKit client for environment variable management */ class EnvKit { /** * Create a new EnvKit client * @param config Configuration options */ constructor(config) { this.config = { fallbackPath: '/env-setup', isProduction: process.env.NODE_ENV === 'production', ...config }; // Validate config if (!Array.isArray(this.config.requiredVars)) { throw new Error('requiredVars must be an array of strings'); } } /** * Validate environment variables based on the current configuration * @param env Environment variables to validate * @returns Validation result with success flag and missing variables */ validateEnvironment(env) { const schema = (0, schema_1.createEnvSchema)(this.config.requiredVars, this.config.optionalVars); return (0, schema_1.validateEnv)(schema, env); } /** * Get the configuration for EnvKitProvider * @returns Provider configuration object */ getProviderConfig() { return { requiredVars: this.config.requiredVars, fallbackPath: this.config.fallbackPath, isProduction: this.config.isProduction, }; } } exports.EnvKit = EnvKit; /** * Create a new EnvKit client with the specified configuration * @param config Configuration options * @returns EnvKit client instance */ function createEnvKit(config) { return new EnvKit(config); } //# sourceMappingURL=client.js.map