UNPKG

hypertune

Version:

[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Opt

42 lines 2.04 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const parseInitResponse_1 = __importDefault(require("../parseInitResponse")); class VercelEdgeConfigInitDataProvider { constructor({ edgeConfigClient, itemKey, }) { this.edgeConfigClient = edgeConfigClient; this.itemKey = itemKey; } // eslint-disable-next-line class-methods-use-this getName() { return "Vercel Edge Config"; } getInitData() { return __awaiter(this, void 0, void 0, function* () { const rawResponse = yield this.edgeConfigClient.get(this.itemKey); if (!rawResponse) { throw new Error(`[initFromEdgeConfig] no value for key ${this.itemKey}`); } const response = typeof rawResponse === "string" ? (0, parseInitResponse_1.default)(rawResponse) : rawResponse; if (!response.commitId) { throw new Error(`[initFromEdgeConfig] unexpected response: ${JSON.stringify(response)}`); } return response; }); } } exports.default = VercelEdgeConfigInitDataProvider; //# sourceMappingURL=VercelEdgeConfigInitDataProvider.js.map