1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/lib/strategyApi.js
2020-02-20 08:30:13 +01:00

38 lines
789 B
JavaScript

var strategies = [
{name: "default"},
{
name: "activeForUsers",
configurationTemplate: {
userNames: "String"
}
}
];
function byName(name) {
return strategies.filter(function(s) {
return s.name === name;
})[0];
}
module.exports = function (app) {
app.get('/strategies', function (req, res) {
res.json({features: strategies});
});
app.get('/strategies/:name', function (req, res) {
var strategy = byName(req.params.name);
if (strategy) {
res.json(strategy);
} else {
res.json(404, {error: 'Could not find strategy'});
}
});
app.post('/strategies', function (req, res) {
res.json(500, {error: 'Not implemented yet'});
});
};