Skip to content

Commit 5a6ba11

Browse files
committed
wip
1 parent 63b5174 commit 5a6ba11

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

spec/RateLimit.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ describe('rate limit', () => {
447447
validateRateLimit({
448448
rateLimit: [{ requestPath: 'a', requestTimeWindow: 1000, requestCount: 3, zone: 'abc' }],
449449
})
450-
).toThrow('rateLimit.zone must be one of global, session, user or ip');
450+
).toThrow('rateLimit.zone must be one of global, session, user, or ip');
451451
expect(() =>
452452
validateRateLimit({
453453
rateLimit: [

src/Config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
SchemaOptions,
1919
SecurityOptions,
2020
} from './Options/Definitions';
21+
import ParseServer from './cloud-code/Parse.Server';
2122

2223
function removeTrailingSlash(str) {
2324
if (!str) {
@@ -599,8 +600,10 @@ export class Config {
599600
if (option.errorResponseMessage && typeof option.errorResponseMessage !== 'string') {
600601
throw `rateLimit.errorResponseMessage must be a string`;
601602
}
602-
if (option.zone && !['global', 'session', 'user', 'ip'].includes(option.zone)) {
603-
throw `rateLimit.zone must be one of global, session, user or ip`;
603+
const options = Object.keys(ParseServer.RateLimitZone);
604+
if (option.zone && !options.includes(option.zone)) {
605+
const formatter = new Intl.ListFormat('en', { style: 'short', type: 'disjunction' });
606+
throw `rateLimit.zone must be one of ${formatter.format(options)}`;
604607
}
605608
}
606609
}

0 commit comments

Comments
 (0)