mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-21 16:52:04 -07:00
Merge pull request #133 from Permissionless-Software-Foundation/ct-unstable
Updating example start shell script
This commit is contained in:
@@ -30,6 +30,7 @@ start-fullstack-abc.sh
|
||||
start-fullstack-bchn.sh
|
||||
start-ss-main.sh
|
||||
start-decatur-bchn.sh
|
||||
shell-scripts/
|
||||
|
||||
coverage
|
||||
start-my-infra
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
"coverage:report": "export NETWORK=mainnet && nyc --reporter=html mocha --timeout 25000 test/v4/",
|
||||
"docs": "./node_modules/.bin/apidoc -i src/routes/v4 -o docs",
|
||||
"test:temp1": "export NETWORK=mainnet && export TEST=integration && mocha --exit --timeout 25000 -g '#hydrateUtxos-' test/v4/integration/",
|
||||
"test:temp2": "mocha test/v4/rate-limit2-unit.js"
|
||||
"test:temp2": "mocha -g '#rate-routelimit' --timeout 30000 test/v4/"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.15.1"
|
||||
|
||||
@@ -154,6 +154,7 @@ class RateLimits {
|
||||
res,
|
||||
defaultJwt
|
||||
)
|
||||
// console.log(`hasExceededRateLimit: `, hasExceededRateLimit)
|
||||
|
||||
if (!hasExceededRateLimit) {
|
||||
// Rate limits have not been exceeded. Processing can continue.
|
||||
@@ -195,6 +196,7 @@ class RateLimits {
|
||||
res,
|
||||
req.locals.jwtToken
|
||||
)
|
||||
// console.log('hasExceededRateLimit: ', hasExceededRateLimit)
|
||||
|
||||
if (!hasExceededRateLimit) {
|
||||
// Rate limits have not been exceeded. Processing can continue.
|
||||
@@ -220,8 +222,12 @@ class RateLimits {
|
||||
async trackRateLimits (req, res, jwtToken) {
|
||||
// Anonymous rate limits are used by default.
|
||||
let pointsToConsume = ANON_LIMITS
|
||||
// console.log('pointsToConsume: ', pointsToConsume)
|
||||
|
||||
let key = req.ip // Use the IP address as the key, by default.
|
||||
|
||||
// console.log('jwtToken: ', jwtToken)
|
||||
|
||||
try {
|
||||
// Decode the JWT token if it exists
|
||||
if (jwtToken) {
|
||||
@@ -239,6 +245,10 @@ class RateLimits {
|
||||
// The 429 error response is handled by the catch().
|
||||
await _this.rateLimiter.consume(key, pointsToConsume)
|
||||
|
||||
// Debugging
|
||||
// const rateLimitData = await _this.rateLimiter.consume(key, pointsToConsume)
|
||||
// console.log(`rateLimitData: `, rateLimitData)
|
||||
|
||||
res.locals.pointsToConsume = pointsToConsume // Feedback for tests.
|
||||
|
||||
// Signal that the user has not exceeded their rate limits.
|
||||
|
||||
@@ -48,12 +48,12 @@ export PRO_PASS=somerandomepassword:someotherrandompassword:aThirdPassword
|
||||
# that originate froma domain on the whitelist.
|
||||
export WHITELIST_DOMAINS=fullstack.cash,psfoundation.cash,torlist.cash
|
||||
|
||||
# Rate Limits. Numbers are divided into 1000. e.g. 1000 / 50 = 20 RPM for ANON.
|
||||
# Rate Limits. Numbers are divided into 1000. e.g. 10000 / 500 = 20 RPM for ANON.
|
||||
# Requests use the ANON rate limit if they fail to pass in a JWT token.
|
||||
# ANON = 20 requests per minute (RPM)
|
||||
export ANON_RATE_LIMIT=50
|
||||
# 10 = 100 RPM
|
||||
export WHITELIST_RATE_LIMIT=10
|
||||
export ANON_RATE_LIMIT=500
|
||||
# 10 = 1000 RPM
|
||||
export WHITELIST_RATE_LIMIT=100
|
||||
|
||||
# Set logging parameters
|
||||
#1m means no more than 1 megabyte
|
||||
|
||||
@@ -250,6 +250,7 @@ describe('#Raw-Transactions', () => {
|
||||
'Proper error message'
|
||||
)
|
||||
})
|
||||
|
||||
it('returns proper error when downstream service stalls', async () => {
|
||||
req.body.hexes = [
|
||||
'0200000001b9b598d7d6d72fc486b2b3a3c03c79b5bade6ec9a77ced850515ab5e64edcc21010000006b483045022100a7b1b08956abb8d6f322aa709d8583c8ea492ba0585f1a6f4f9983520af74a5a0220411aee4a9a54effab617b0508c504c31681b15f9b187179b4874257badd4139041210360cfc66fdacb650bc4c83b4e351805181ee696b7d5ab4667c57b2786f51c413dffffffff0210270000000000001976a914eb4b180def88e3f5625b2d8ae2c098ff7d85f66488ac786e9800000000001976a914eb4b180def88e3f5625b2d8ae2c098ff7d85f66488ac00000000'
|
||||
|
||||
Reference in New Issue
Block a user