mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-22 09:12:05 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2817300ad6 | ||
|
|
4aa7cad552 | ||
|
|
5a9401aeb1 | ||
|
|
0ae02790a2 | ||
|
|
4d3adab9e0 | ||
|
|
91f06b6311 | ||
|
|
2fc175d818 | ||
|
|
731861cb1d | ||
|
|
9a01f5ffe6 | ||
|
|
c62c515474 |
@@ -12,6 +12,8 @@
|
|||||||
// req.locals.jwtToken property.
|
// req.locals.jwtToken property.
|
||||||
const getTokenFromHeaders = (req, res, next) => {
|
const getTokenFromHeaders = (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
|
// console.log('req.headers: ', req.headers)
|
||||||
|
|
||||||
// Only executes if the authorization header exists.
|
// Only executes if the authorization header exists.
|
||||||
if (req.headers.authorization) {
|
if (req.headers.authorization) {
|
||||||
// Retrieve the auth string from the header object.
|
// Retrieve the auth string from the header object.
|
||||||
|
|||||||
@@ -221,7 +221,9 @@ class RateLimits {
|
|||||||
// should be returned by the middleware.
|
// should be returned by the middleware.
|
||||||
async trackRateLimits (req, res, jwtToken) {
|
async trackRateLimits (req, res, jwtToken) {
|
||||||
const debugInfo = {
|
const debugInfo = {
|
||||||
jwtToken
|
jwtToken,
|
||||||
|
userObj: req.body.usrObj,
|
||||||
|
locals: req.locals
|
||||||
}
|
}
|
||||||
|
|
||||||
// Anonymous rate limits are used by default.
|
// Anonymous rate limits are used by default.
|
||||||
@@ -268,9 +270,9 @@ class RateLimits {
|
|||||||
res.locals.rateLimitTriggered = true
|
res.locals.rateLimitTriggered = true
|
||||||
// console.log('res.locals: ', res.locals)
|
// console.log('res.locals: ', res.locals)
|
||||||
|
|
||||||
console.log(
|
// console.log(
|
||||||
`rate limit debug info: ${JSON.stringify(debugInfo, null, 2)}`
|
// `rate limit debug info: ${JSON.stringify(debugInfo, null, 2)}`
|
||||||
)
|
// )
|
||||||
|
|
||||||
// Rate limited was triggered
|
// Rate limited was triggered
|
||||||
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
|
||||||
|
|||||||
Reference in New Issue
Block a user