@trendmoon/api-client
Version:
Official TypeScript client for Trendmoon API
39 lines • 1.38 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.config = void 0;
const zod_1 = require("zod");
const dotenv_1 = __importDefault(require("dotenv"));
dotenv_1.default.config();
const envSchema = zod_1.z.object({
TRENDMOON_API_KEY: zod_1.z.string(),
TRENDMOON_API_URL: zod_1.z.string(),
});
/**
* Validates that an environment variable is defined
* @param name - The environment variable name
* @param value - The environment variable value
* @returns The validated value
* @throws Error if the variable is not defined
*/
function validateEnvVar(name, value) {
if (!value) {
throw new Error(`Environment variable ${name} is required but not defined`);
}
return value;
}
/**
* Environment configuration with necessary variables for Trendmoon API
*/
exports.config = {
// API key required for authentication
TRENDMOON_API_KEY: validateEnvVar('TRENDMOON_API_KEY', process.env.TRENDMOON_API_KEY),
// API URL with default value for QA environment
TRENDMOON_API_URL: process.env.TRENDMOON_API_URL || 'https://api.qa.trendmoon.ai',
};
// Environment schema validation
envSchema.parse(exports.config);
exports.default = exports.config;
//# sourceMappingURL=env.js.map