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:
Lucas
2025-12-12 19:36:27 +01:00
committed by GitHub
parent 5a61993cb7
commit fa8723b3d1
10 changed files with 100 additions and 105 deletions

View File

@@ -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`;
}