UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

42 lines 1.34 kB
import NotFoundError from '../../lib/error/notfound-error.js'; export default class FakeFeatureTypeStore { constructor() { this.featureTypes = []; } async delete(key) { this.featureTypes.splice(this.featureTypes.findIndex((type) => type.id === key), 1); } async deleteAll() { this.featureTypes = []; } destroy() { } async exists(key) { return this.featureTypes.some((fT) => fT.id === key); } async get(key) { const type = this.featureTypes.find((fT) => fT.id === key); if (type) { return type; } throw new NotFoundError(`Could not find feature type with id : ${key}`); } async getAll() { return this.featureTypes; } async getByName(name) { const type = this.featureTypes.find((fT) => fT.name === name); if (type) { return type; } throw new NotFoundError(`Could not find feature type with name: ${name}`); } async updateLifetime(name, newLifetimeDays) { const featureType = this.featureTypes.find(({ name: type }) => type === name); if (!featureType) { return undefined; } featureType.lifetimeDays = newLifetimeDays; return featureType; } } //# sourceMappingURL=fake-feature-type-store.js.map