This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CircuitBreaker { | |
constructor(request) { | |
this.request = request | |
this.state = "CLOSED" | |
this.failureThreshold = 3 | |
this.failureCount = 0 | |
this.successThreshold = 2 | |
this.successCount = 0 | |
this.timeout = 6000 | |
this.nextAttempt = Date.now() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CircuitBreaker { | |
constructor(request, options = {}) { | |
const defaults = { | |
failureThreshold: 3, | |
successThreshold: 2, | |
timeout: 6000 | |
} | |
Object.assign(this, defaults, options, { | |
request, | |
state: "CLOSED", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require("isomorphic-unfetch"); | |
const querystring = require("querystring"); | |
class DevTo { | |
constructor(config) { | |
this.api_key = config.api_key; | |
this.basePath = "https://dev.to/api"; | |
} | |
request(endpoint = "", options = {}) { | |
let url = this.basePath + endpoint; |
OlderNewer