Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
AWS.config.update({ region, accessKeyId, secretAccessKey })
this._rekognition = Promise.promisifyAll(new AWS.Rekognition())
this._circuitBreaker = new Brakes(this._options.breaker)
this._rekognition.listCollectionsCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._rekognition.listCollectionsAsync(params), this._options.retry))
this._rekognition.createCollectionCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._rekognition.createCollectionAsync(params), this._options.retry))
this._rekognition.indexFacesCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._rekognition.indexFacesAsync(params), this._options.retry))
this._rekognition.listFacesCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._rekognition.listFacesAsync(params), this._options.retry))
this._rekognition.deleteFacesCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._rekognition.deleteFacesAsync(params), this._options.retry))
this._rekognition.detectFacesCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._rekognition.detectFacesAsync(params), this._options.retry))
this._rekognition.detectLabelsCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._rekognition.detectLabelsAsync(params), this._options.retry))
this._rekognition.searchFacesByImageCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._rekognition.searchFacesByImageAsync(params), this._options.retry))
Health.addCheck('rekognition', () => new Promise((resolve, reject) => {
if (this._circuitBreaker.isOpen()) {
return reject(new Error(`circuit breaker is open`))
} else {
return resolve()
}
}))
}
constructor (options = {}) {
this._options = _.defaults(options, defaultOptions)
this._breaker = new Brakes(this._options.breaker)
this._authorizeAppCircuitBreaker = this._breaker.slaveCircuit((...params) => retry(() => authorizeApp.bind(this)(...params), this._options.retry))
Health.addCheck('facebook', () => new Promise((resolve, reject) => {
if (this._breaker.isOpen()) {
return reject(new Error(`circuit breaker is open`))
} else {
return resolve()
}
}))
}
AWS.config.update({ region, accessKeyId, secretAccessKey })
this._s3 = Promise.promisifyAll(new AWS.S3())
this._circuitBreaker = new Brakes(this._options.breaker)
this._s3.listBucketsCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._s3.listBucketsAsync(params), this._options.retry))
this._s3.createBucketCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._s3.createBucketAsync(params), this._options.retry))
this._s3.putBucketPolicyCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._s3.putBucketPolicyAsync(params), this._options.retry))
this._s3.putObjectCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._s3.putObjectAsync(params), this._options.retry))
this._s3.copyObjectCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._s3.copyObjectAsync(params), this._options.retry))
this._s3.getObjectCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._s3.getObjectAsync(params), this._options.retry))
this._s3.deleteObjectCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._s3.deleteObjectAsync(params), this._options.retry))
this._s3.listObjectsCircuitBreaker = this._circuitBreaker.slaveCircuit((params) => retry(() => this._s3.listObjectsAsync(params), this._options.retry))
Health.addCheck('s3', () => new Promise((resolve, reject) => {
if (this._circuitBreaker.isOpen()) {
return reject(new Error(`circuit breaker is open`))
} else {
return resolve()
}
}))
}
constructor (options = {}) {
super('happn')
this._options = _.defaults(options, defaultOptions)
this._happn = new HappnWrapper()
Health.addCheck(this.name, () => new Promise((resolve, reject) => {
if (this._happn.circuitBreaker.isOpen()) {
return reject(new Error(`circuit breaker is open`))
} else {
return resolve()
}
}))
}
constructor (options = {}) {
super(_.defaultsDeep({}, options, defaultOptions))
Health.addCheck('rtp-play', async () => {
if (this.circuitBreaker.isOpen()) {
throw new Error(`circuit breaker is open`)
}
})
}
}
const _ = require('lodash')
const Promise = require('bluebird')
const Logger = require('modern-logger')
const Health = require('health-checkup')
const FacebookLogin = require('facebook-login-for-robots')
const facebookLogin = new FacebookLogin({
facebook: {
email: FACEBOOK_USER_EMAIL,
password: FACEBOOK_USER_PASSWORD
}
})
Health.addCheck('facebook', () => Promise.try(() => {
if (facebookLogin.circuitBreaker.isOpen()) {
throw new Error(`circuit breaker is open`)
}
}))
const { OutOfLikesError } = require('./errors')
const Database = require('../database')
const createChannelIfNeeded = function () {
return Database.channels.find({ where: { name: this._name } })
.then((channel) => {
if (!channel) {
return Database.channels.create(_.assign({ name: this._name }, this._options.channel))
}
})
constructor (options = {}) {
super('tinder')
this._options = _.defaults(options, defaultOptions)
this._tinder = new TinderWrapper()
Health.addCheck(this.name, () => new Promise((resolve, reject) => {
if (this._tinder.circuitBreaker.isOpen()) {
return reject(new Error(`circuit breaker is open`))
} else {
return resolve()
}
}))
}
handler (request, reply) {
return Health.checkup()
.then((status) => {
const statusCode = _.find(status, (check) => !check.is_healthy) ? 503 : 200
return reply(null, { status }).code(statusCode)
})
}