// start express server app.listen(process.env.PORT, () => { // create spark webhook directed back to express route defined above spark.webhooksGet() .then(webhooks => when.map(webhooks, webhook => spark.webhookRemove(webhook.id))) .then(() => spark.webhookAdd({ name: 'my webhook', targetUrl: 'http://mywebhost.com/webhook', resource: 'all', event: 'all', })); console.log(`Listening on port ${process.env.PORT}`); });
/** * Clean container by removing all entries no present in the resource list. * @param {String} container Container name * @param {Object[]} resources Resource list * @retrun {Promise} Promise of the action */ var cleanContainer = function (container, resources) { var keys = _.pluck(resources, 'key') // TODO remove zero length files // List directory content... logger.debug('Cleanup S3 container: %s', container) return _listContainer(container) .then(function (entries) { // Get delta between directory content and key list var delta = _.difference(entries, keys) return when.map(delta, function (entry) { // Remove files delta. logger.debug('Removing unused resource: %s ...', entry) return remove(container, entry) }) }) }
// start express server app.listen(process.env.PORT, () => { // create spark webhook directed back to express route defined above spark.webhooksGet() .then(webhooks => when.map(webhooks, webhook => spark.webhookRemove(webhook.id))) .then(() => spark.webhookAdd({ name: 'my webhook', targetUrl: 'http://mywebhost.com/webhook', resource: 'all', event: 'all', })); console.log(`Listening on port ${process.env.PORT}`); });