Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for toggle types (#618)
- Loading branch information
Showing
17 changed files
with
258 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
id: events | ||
title: /api/admin/feature-types | ||
--- | ||
|
||
# Feature Types API | ||
|
||
`GET: http://unleash.host.com/api/admin/feature-types` | ||
|
||
Used to fetch all feature types defined in the unleash system. | ||
|
||
**Response** | ||
|
||
```json | ||
{ | ||
"version": 1, | ||
"types": [ | ||
{ | ||
"id": "release", | ||
"name": "Release", | ||
"description": "Used to enable trunk-based development for teams practicing Continuous Delivery.", | ||
"lifetimeDays": 40 | ||
}, | ||
{ | ||
"id": "experiment", | ||
"name": "Experiment", | ||
"description": "Used to perform multivariate or A/B testing.", | ||
"lifetimeDays": 40 | ||
}, | ||
{ | ||
"id": "ops", | ||
"name": "Operational", | ||
"description": "Used to control operational aspects of the system behavior.", | ||
"lifetimeDays": 7 | ||
}, | ||
{ | ||
"id": "killswitch", | ||
"name": "Kill switch", | ||
"description": "Used to to gracefully degrade system functionality.", | ||
"lifetimeDays": null | ||
}, | ||
{ | ||
"id": "permission", | ||
"name": "Permission", | ||
"description": "Used to change the features or product experience that certain users receive.", | ||
"lifetimeDays": null | ||
} | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const COLUMNS = ['id', 'name', 'description', 'lifetime_days']; | ||
const TABLE = 'feature_types'; | ||
|
||
class FeatureToggleStore { | ||
constructor(db, getLogger) { | ||
this.db = db; | ||
this.getLogger = getLogger('feature-type-store.js'); | ||
} | ||
|
||
getAll() { | ||
return this.db | ||
.select(COLUMNS) | ||
.from(TABLE) | ||
.map(this.rowToFeatureType); | ||
} | ||
|
||
rowToFeatureType(row) { | ||
return { | ||
id: row.id, | ||
name: row.name, | ||
description: row.description, | ||
lifetimeDays: row.lifetime_days, | ||
}; | ||
} | ||
} | ||
|
||
module.exports = FeatureToggleStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
const Controller = require('../controller'); | ||
|
||
const version = 1; | ||
|
||
class FeatureTypeController extends Controller { | ||
constructor(config) { | ||
super(config); | ||
this.featureTypeStore = config.stores.featureTypeStore; | ||
this.logger = config.getLogger('/admin-api/feature-type.js'); | ||
|
||
this.get('/', this.getAllFeatureTypes); | ||
} | ||
|
||
async getAllFeatureTypes(req, res) { | ||
const types = await this.featureTypeStore.getAll(); | ||
res.json({ version, types }); | ||
} | ||
} | ||
|
||
module.exports = FeatureTypeController; |
Oops, something went wrong.