mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
parent
fc42827641
commit
c20252d9d7
@ -1,5 +1,6 @@
|
||||
module.exports = {
|
||||
featureCreated : 'feature-created',
|
||||
featureUpdated : 'feature-updated',
|
||||
strategyCreated: 'strategy-created'
|
||||
strategyCreated: 'strategy-created',
|
||||
strategyDeleted: 'strategy-deleted'
|
||||
};
|
@ -16,6 +16,18 @@ module.exports = function (app) {
|
||||
.catch(function () { res.json(404, {error: 'Could not find strategy'}); });
|
||||
});
|
||||
|
||||
app.delete('/strategies/:name', function (req, res) {
|
||||
eventStore.create({
|
||||
type: eventType.strategyDeleted,
|
||||
createdBy: req.connection.remoteAddress,
|
||||
data: {
|
||||
name: req.params.name
|
||||
}
|
||||
})
|
||||
.then(function () { res.status(200).end(); })
|
||||
.catch(function () { res.status(500).end(); });
|
||||
});
|
||||
|
||||
app.post('/strategies', function (req, res) {
|
||||
req.checkBody('name', 'Name is required').notEmpty();
|
||||
req.checkBody('name', 'Name must match format ^[a-zA-Z\\.\\-]+$').matches(/^[a-zA-Z\\.\\-]+$/i);
|
||||
|
@ -12,6 +12,15 @@ eventStore.on(eventType.strategyCreated, function (event) {
|
||||
});
|
||||
});
|
||||
|
||||
eventStore.on(eventType.strategyDeleted, function (event) {
|
||||
knex('strategies')
|
||||
.where('name', event.data.name)
|
||||
.del()
|
||||
.catch(function (err) {
|
||||
logger.error('Could not delete strategy, error was: ', err);
|
||||
});
|
||||
});
|
||||
|
||||
function getStrategies() {
|
||||
return knex
|
||||
.select(STRATEGY_COLUMNS)
|
||||
|
@ -44,5 +44,9 @@ describe('The strategy api', function () {
|
||||
.expect(403, done);
|
||||
});
|
||||
|
||||
|
||||
it('deletes a new strategy', function (done) {
|
||||
request
|
||||
.delete('/strategies/deletable')
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
@ -11,6 +11,10 @@ var strategies = [
|
||||
parametersTemplate: {
|
||||
emails: "String"
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "deletable",
|
||||
description: "deletable"
|
||||
}
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user