Skip to content

Commit f17c7f0

Browse files
committed
feat: add getConfiguration() method
1 parent 86f6e0b commit f17c7f0

4 files changed

+16
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ const limiter = FirebaseFunctionsRateLimiter.mock()
195195
196196
- `isQuotaAlreadyExceeded(qualifier?: string)` — Checks if quota was exceed, but does not record a usage. If you use this, you must call isQuotaExceededOrRecordUsage() to record the usage.
197197
198+
- `getConfiguration()` — Returns this rate limiter configuration.
198199
199200
200201
- ~~`isQuotaExceeded(qualifier?: string)`~~ — **deprecated**: renamed to isQuotaExceededOrRecordUsage

src/FirebaseFunctionsRateLimiter.integration.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ describe("FirebaseFunctionsRateLimiter", () => {
254254
expect(_.keys(collection).length).to.be.equal(1);
255255
});
256256
});
257+
258+
describe("getConfiguration", () => {
259+
it("Returns correct configuration", () => {
260+
const { rateLimiter, config } = mock("firestore", { maxCalls: 5 });
261+
expect(rateLimiter.getConfiguration()).to.deep.include(config);
262+
});
263+
});
257264
}),
258265
);
259266
});

src/FirebaseFunctionsRateLimiter.mock.integration.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ export function mock(
4949
uniqueDocName,
5050
rateLimiter,
5151
getDocument,
52+
config,
5253
};
5354
}

src/FirebaseFunctionsRateLimiter.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ export class FirebaseFunctionsRateLimiter {
146146
);
147147
}
148148

149+
/**
150+
* Returns this rate limiter configuration
151+
*/
152+
public getConfiguration(): FirebaseFunctionsRateLimiterConfiguration {
153+
return this.configurationFull;
154+
}
155+
149156
/*
150157
* Private methods
151158
*/

0 commit comments

Comments
 (0)