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 = {
|
module.exports = {
|
||||||
featureCreated : 'feature-created',
|
featureCreated : 'feature-created',
|
||||||
featureUpdated : 'feature-updated',
|
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'}); });
|
.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) {
|
app.post('/strategies', function (req, res) {
|
||||||
req.checkBody('name', 'Name is required').notEmpty();
|
req.checkBody('name', 'Name is required').notEmpty();
|
||||||
req.checkBody('name', 'Name must match format ^[a-zA-Z\\.\\-]+$').matches(/^[a-zA-Z\\.\\-]+$/i);
|
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() {
|
function getStrategies() {
|
||||||
return knex
|
return knex
|
||||||
.select(STRATEGY_COLUMNS)
|
.select(STRATEGY_COLUMNS)
|
||||||
|
@ -44,5 +44,9 @@ describe('The strategy api', function () {
|
|||||||
.expect(403, done);
|
.expect(403, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('deletes a new strategy', function (done) {
|
||||||
|
request
|
||||||
|
.delete('/strategies/deletable')
|
||||||
|
.expect(200, done);
|
||||||
|
});
|
||||||
});
|
});
|
@ -11,6 +11,10 @@ var strategies = [
|
|||||||
parametersTemplate: {
|
parametersTemplate: {
|
||||||
emails: "String"
|
emails: "String"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "deletable",
|
||||||
|
description: "deletable"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user