feat: massive update

Signed-off-by: Ricardo Arturo Cabral Mejía <me@ricardocabral.io>
This commit is contained in:
Ricardo Arturo Cabral Mejía
2023-01-27 02:57:20 -05:00
parent 55561847e8
commit f9c53eeeb8
80 changed files with 2131 additions and 682 deletions

View File

@@ -47,22 +47,4 @@ describe('getRemoteAddress', () => {
)
).to.equal(socketAddress)
})
it('returns undefined if unable to find header', () => {
expect(
getRemoteAddress(
{ ...request, socket: {} } as any,
{ network: {} } as any,
)
).to.be.undefined
})
it('returns undefined if header setting is unset', () => {
expect(
getRemoteAddress(
{ ...request, socket: {} } as any,
{} as any,
)
).to.be.undefined
})
})

View File

@@ -14,6 +14,9 @@ describe('SlidingWindowRateLimiter', () => {
let addToSortedSetStub: Sinon.SinonStub
let getRangeFromSortedSetStub: Sinon.SinonStub
let setKeyExpiryStub: Sinon.SinonStub
let getKeyStub: Sinon.SinonStub
let hasKeyStub: Sinon.SinonStub
let setKeyStub: Sinon.SinonStub
let sandbox: Sinon.SinonSandbox
@@ -24,11 +27,17 @@ describe('SlidingWindowRateLimiter', () => {
addToSortedSetStub = sandbox.stub()
getRangeFromSortedSetStub = sandbox.stub()
setKeyExpiryStub = sandbox.stub()
getKeyStub = sandbox.stub()
hasKeyStub = sandbox.stub()
setKeyStub = sandbox.stub()
cache = {
removeRangeByScoreFromSortedSet: removeRangeByScoreFromSortedSetStub,
addToSortedSet: addToSortedSetStub,
getRangeFromSortedSet: getRangeFromSortedSetStub,
setKeyExpiry: setKeyExpiryStub,
getKey: getKeyStub,
hasKey: hasKeyStub,
setKey: setKeyStub,
}
rateLimiter = new SlidingWindowRateLimiter(cache)
})