mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-01 00:08:27 +01:00
#34 added a mock for the strategies templeates
This commit is contained in:
parent
0256d357eb
commit
6d93e46733
37
unleash-server/lib/strategyApi.js
Normal file
37
unleash-server/lib/strategyApi.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
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'});
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -5,6 +5,7 @@ var express = require('express'),
|
|||||||
routes = require('./lib/routes'),
|
routes = require('./lib/routes'),
|
||||||
eventApi = require('./lib/eventApi'),
|
eventApi = require('./lib/eventApi'),
|
||||||
featureApi = require('./lib/featureApi'),
|
featureApi = require('./lib/featureApi'),
|
||||||
|
strategyApi = require('./lib/strategyApi'),
|
||||||
validator = require('express-validator'),
|
validator = require('express-validator'),
|
||||||
app = express(),
|
app = express(),
|
||||||
router = express.Router(),
|
router = express.Router(),
|
||||||
@ -35,6 +36,7 @@ app.use(bodyParser.json({strict: false}));
|
|||||||
|
|
||||||
eventApi(router);
|
eventApi(router);
|
||||||
featureApi(router);
|
featureApi(router);
|
||||||
|
strategyApi(router);
|
||||||
routes(router);
|
routes(router);
|
||||||
app.use(baseUriPath, router);
|
app.use(baseUriPath, router);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user