@universis/janitor
Version:
Universis api plugin for handling user authorization and rate limiting
116 lines • 4.55 kB
JSON
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"id": "urn:universis:speed-limit-service:1",
"description": "@universis/janitor#SpeedLimitService configuration schema",
"properties": {
"storeType": {
"type": "string",
"description": "The type of store to use for speed limiting e.g. @universis/janitor#RedisClientStore"
},
"profiles": {
"description": "A named collection of speed limit configurations",
"type": "array",
"items": [
{
"type": "array",
"items": [
{
"type": "string",
"description": "The name of current speed limit profile."
},
{
"type": "object",
"properties": {
"windowMs": {
"description": "milliseconds - how long to keep records of requests in memory. Defaults to 60000 (1 minute)",
"type": "integer"
},
"delayMs": {
"description": "milliseconds - how long to delay the response, multiplied by (number of recent hits - delayAfter). Defaults to 1000 (1 second). Set to 0 to disable delaying.",
"type": "integer"
},
"delayAfter": {
"description": "max number of connections during windowMs before starting to delay responses. Number or function that returns a number. Defaults to 1.",
"type": "integer"
},
"randomDelayMs": {
"description": "random milliseconds - a random value between the given range for defining delayMs",
"type": "array",
"items": [
{
"type": "integer"
},
{
"type": "integer"
}
]
},
"maxDelayMs": {
"description": "milliseconds - maximum value for delayMs after many consecutive attempts, that is, after the n-th request, the delay will be always maxDelayMs. Important when your application is running behind a load balancer or reverse proxy that has a request timeout. Defaults to Infinity.",
"type": "integer"
},
"randomMaxDelayMs": {
"description": "random milliseconds - a random value between the given range for delayMs after many consecutive attempts, that is, after the n-th request, the delay will be always maxDelayMs.",
"type": "array",
"items": [
{
"type": "integer"
},
{
"type": "integer"
}
]
},
"skipFailedRequests": {
"description": "when true failed requests (response status >= 400) won't be counted. Defaults to false.",
"type": "boolean"
},
"skipSuccessfulRequests": {
"description": "when true successful requests (response status < 400) won't be counted. Defaults to false.",
"type": "boolean"
},
"headers": {
"description": "Add X-SlowDown-Limit, X-SlowDown-Remaining, and if the store supports it, X-SlowDown-Reset headers to all responses. Modeled after the equivalent headers in express-rate-limit. Default: false",
"type": "boolean"
}
},
"required": [
"windowMs",
"delayAfter"
]
}
]
}
]
},
"paths": {
"type": "array",
"items": [
{
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"profile": {
"type": "string"
}
},
"required": [
"profile"
]
}
]
}
]
}
},
"required": [
"profiles",
"paths"
]
}