mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
fix: add properties to legacy endpoints (#919)
Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
This commit is contained in:
parent
f2eb3c101f
commit
cdc2e7daee
@ -272,6 +272,7 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
|
|||||||
acc.description = r.description;
|
acc.description = r.description;
|
||||||
acc.stale = r.stale;
|
acc.stale = r.stale;
|
||||||
acc.variants = r.variants;
|
acc.variants = r.variants;
|
||||||
|
acc.createdAt = r.created_at;
|
||||||
acc.lastSeenAt = r.last_seen_at;
|
acc.lastSeenAt = r.last_seen_at;
|
||||||
acc.type = r.type;
|
acc.type = r.type;
|
||||||
if (!acc.environments[r.environment]) {
|
if (!acc.environments[r.environment]) {
|
||||||
|
@ -103,14 +103,20 @@ class FeatureController extends Controller {
|
|||||||
res: Response,
|
res: Response,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const name = req.params.featureName;
|
const name = req.params.featureName;
|
||||||
|
const feature = await this.getLegacyFeatureToggle(name);
|
||||||
|
res.json(feature).end();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getLegacyFeatureToggle(name: string): Promise<any> {
|
||||||
const feature = await this.featureService2.getFeatureToggle(name);
|
const feature = await this.featureService2.getFeatureToggle(name);
|
||||||
const strategies =
|
const globalEnv = feature.environments.find(
|
||||||
feature.environments.find((e) => e.name === GLOBAL_ENV)
|
(e) => e.name === GLOBAL_ENV,
|
||||||
?.strategies || [];
|
);
|
||||||
res.json({
|
const strategies = globalEnv?.strategies || [];
|
||||||
...feature,
|
const enabled = globalEnv?.enabled || false;
|
||||||
strategies,
|
delete feature.environments;
|
||||||
}).end();
|
|
||||||
|
return { ...feature, enabled, strategies };
|
||||||
}
|
}
|
||||||
|
|
||||||
async listTags(req: Request, res: Response): Promise<void> {
|
async listTags(req: Request, res: Response): Promise<void> {
|
||||||
@ -280,22 +286,16 @@ class FeatureController extends Controller {
|
|||||||
async staleOn(req: Request, res: Response): Promise<void> {
|
async staleOn(req: Request, res: Response): Promise<void> {
|
||||||
const { featureName } = req.params;
|
const { featureName } = req.params;
|
||||||
const userName = extractUser(req);
|
const userName = extractUser(req);
|
||||||
const feature = await this.featureService2.updateStale(
|
await this.featureService2.updateStale(featureName, true, userName);
|
||||||
featureName,
|
const feature = await this.getLegacyFeatureToggle(featureName);
|
||||||
true,
|
|
||||||
userName,
|
|
||||||
);
|
|
||||||
res.json(feature).end();
|
res.json(feature).end();
|
||||||
}
|
}
|
||||||
|
|
||||||
async staleOff(req: Request, res: Response): Promise<void> {
|
async staleOff(req: Request, res: Response): Promise<void> {
|
||||||
const { featureName } = req.params;
|
const { featureName } = req.params;
|
||||||
const userName = extractUser(req);
|
const userName = extractUser(req);
|
||||||
const feature = await this.featureService2.updateStale(
|
await this.featureService2.updateStale(featureName, false, userName);
|
||||||
featureName,
|
const feature = await this.getLegacyFeatureToggle(featureName);
|
||||||
false,
|
|
||||||
userName,
|
|
||||||
);
|
|
||||||
res.json(feature).end();
|
res.json(feature).end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user