feat: Update route patterns to use path-to-regexp v8 syntax (#9942)
BREAKING CHANGE: Route pattern syntax across cloud routes and rate-limiting now use the new path-to-regexp v8 syntax; see the [migration guide](https://github.com/parse-community/parse-server/blob/alpha/9.0.0.md) for more details.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// mount is the URL for the root of the API; includes http, domain, etc.
|
||||
|
||||
import { isBoolean, isString } from 'lodash';
|
||||
import { pathToRegexp } from 'path-to-regexp';
|
||||
import net from 'net';
|
||||
import AppCache from './cache';
|
||||
import DatabaseController from './Controllers/DatabaseController';
|
||||
@@ -687,6 +688,14 @@ export class Config {
|
||||
if (typeof option.requestPath !== 'string') {
|
||||
throw `rateLimit.requestPath must be a string`;
|
||||
}
|
||||
|
||||
// Validate that the path is valid path-to-regexp syntax
|
||||
try {
|
||||
pathToRegexp(option.requestPath);
|
||||
} catch (error) {
|
||||
throw `rateLimit.requestPath "${option.requestPath}" is not valid: ${error.message}`;
|
||||
}
|
||||
|
||||
if (option.requestTimeWindow == null) {
|
||||
throw `rateLimit.requestTimeWindow must be defined`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user