2014-10-30 21:10:48 +01:00
|
|
|
var strategies = [
|
|
|
|
{
|
2014-11-03 21:27:47 +01:00
|
|
|
name: "default",
|
|
|
|
description: "Default on or off Strategy."
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "usersWithEmail",
|
|
|
|
description: "Active for users defined in the comma-separated emails-parameter.",
|
2014-11-01 14:52:37 +01:00
|
|
|
parametersTemplate: {
|
2014-11-03 21:27:47 +01:00
|
|
|
emails: "String"
|
2014-10-30 21:10:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
function byName(name) {
|
|
|
|
return strategies.filter(function(s) {
|
|
|
|
return s.name === name;
|
|
|
|
})[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function (app) {
|
|
|
|
|
|
|
|
app.get('/strategies', function (req, res) {
|
2014-11-01 14:52:37 +01:00
|
|
|
res.json({strategies: strategies});
|
2014-10-30 21:10:48 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
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'});
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|