@fntio/infra-client
Version:
Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.
17 lines (16 loc) • 823 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_API_THROTTLE = void 0;
exports.resolveApiThrottle = resolveApiThrottle;
exports.DEFAULT_API_THROTTLE = { rateLimit: 100, burstLimit: 200 };
/** Validated at synth; the bounds are API Gateway's own account-level ceilings (10,000 rps, 5,000 burst). */
function resolveApiThrottle(config) {
const bounded = (field, max) => {
const value = config?.[field] ?? exports.DEFAULT_API_THROTTLE[field];
if (!Number.isInteger(value) || value < 1 || value > max) {
throw new Error(`apiThrottle.${field} (${String(config?.[field])}) must be an integer from 1 to ${max}.`);
}
return value;
};
return { rateLimit: bounded("rateLimit", 10_000), burstLimit: bounded("burstLimit", 5_000) };
}