fix schemas

This commit is contained in:
yusing 2025-01-19 00:18:52 +08:00
parent 1a83c739d4
commit fe2437a691
18 changed files with 2562 additions and 1966 deletions

View file

@ -72,11 +72,26 @@ build-docker:
docker build -t godoxy-nightly \
--build-arg VERSION="${VERSION}-nightly-${BUILD_DATE}" .
gen-schema-single:
typescript-json-schema --noExtraProps --required --skipLibCheck --tsNodeRegister=true -o schemas/${OUT} schemas/${IN} ${CLASS}
gen-schema:
typescript-json-schema --required --constAsEnum --tsNodeRegister=true -o schemas/config.schema.json schemas/config/config.ts Config
typescript-json-schema --required --constAsEnum --tsNodeRegister=true -o schemas/routes.schema.json schemas/providers/routes.ts Routes
typescript-json-schema --required --constAsEnum --tsNodeRegister=true -o schemas/middleware_compose.schema.json schemas/middlewares/middleware_compose.ts MiddlewareComposeConfig
# typescript-json-schema --required --constAsEnum --tsNodeRegister=true -o schemas/docker_routes.schema.json schemas/docker.ts DockerRoutes
make IN=config/config.ts \
CLASS=Config \
OUT=config.schema.json \
gen-schema-single
make IN=providers/routes.ts \
CLASS=Routes \
OUT=routes.schema.json \
gen-schema-single
make IN=middlewares/middleware_compose.ts \
CLASS=MiddlewareCompose \
OUT=middleware_compose.schema.json \
gen-schema-single
make IN=docker.ts \
CLASS=DockerRoutes \
OUT=docker_routes.schema.json \
gen-schema-single
push-github:
git push origin $(shell git rev-parse --abbrev-ref HEAD)

File diff suppressed because it is too large Load diff

View file

@ -4,9 +4,6 @@ export const ACCESS_LOG_FORMATS = ["combined", "common", "json"] as const;
export type AccessLogFormat = (typeof ACCESS_LOG_FORMATS)[number];
/**
* @additionalProperties false
*/
export type AccessLogConfig = {
/**
* The size of the buffer.

View file

@ -11,6 +11,7 @@ export const AUTOCERT_PROVIDERS = [
export type AutocertProvider = (typeof AUTOCERT_PROVIDERS)[number];
export type AutocertConfig =
| LocalOptions
| CloudflareOptions
| CloudDNSOptions
| DuckDNSOptions
@ -28,32 +29,25 @@ export interface AutocertConfigBase {
key_path?: string;
}
/**
* @additionalProperties false
*/
export interface LocalOptions extends AutocertConfigBase {
provider: "local";
}
export interface CloudflareOptions extends AutocertConfigBase {
provider: "cloudflare";
options: { auth_token: string };
}
/**
* @additionalProperties false
*/
export interface CloudDNSOptions extends AutocertConfigBase {
provider: "clouddns";
options: {
client_id: string;
/**
* @format email
*/
email: Email;
password: string;
};
}
/**
* @additionalProperties false
*/
export interface DuckDNSOptions extends AutocertConfigBase {
provider: "duckdns";
options: {
@ -73,9 +67,6 @@ export const OVH_ENDPOINTS = [
export type OVHEndpoint = (typeof OVH_ENDPOINTS)[number];
/**
* @additionalProperties false
*/
export interface OVHOptionsWithAppKey extends AutocertConfigBase {
provider: "ovh";
options: {
@ -86,9 +77,6 @@ export interface OVHOptionsWithAppKey extends AutocertConfigBase {
};
}
/**
* @additionalProperties false
*/
export interface OVHOptionsWithOAuth2Config extends AutocertConfigBase {
provider: "ovh";
options: {

View file

@ -4,9 +4,6 @@ import { EntrypointConfig } from "./entrypoint";
import { HomepageConfig } from "./homepage";
import { Providers } from "./providers";
/**
* @additionalProperties false
*/
export type Config = {
/** Optional autocert configuration
*

View file

@ -1,15 +1,12 @@
import { MiddlewareComposeConfig } from "../middlewares/middleware_compose";
import { MiddlewareCompose } from "../middlewares/middleware_compose";
import { AccessLogConfig } from "./access_log";
/**
* @additionalProperties false
*/
export type EntrypointConfig = {
/** Entrypoint middleware configuration
*
* @examples require(".").middlewaresExamples
*/
middlewares: MiddlewareComposeConfig;
middlewares: MiddlewareCompose;
/** Entrypoint access log configuration
*
* @examples require(".").accessLogExamples

View file

@ -1,6 +1,3 @@
/**
* @additionalProperties false
*/
export type HomepageConfig = {
/**
* Use default app categories (uses docker image name)

View file

@ -5,19 +5,12 @@ export const NOTIFICATION_PROVIDERS = ["webhook", "gotify"] as const;
export type NotificationProvider = (typeof NOTIFICATION_PROVIDERS)[number];
export type NotificationConfig = {
/**
* Name of the notification provider
*/
/* Name of the notification provider */
name: string;
/**
* URL of the notification provider
*/
/* URL of the notification provider */
url: URL;
};
/**
* @additionalProperties false
*/
export interface GotifyConfig extends NotificationConfig {
provider: "gotify";
/* Gotify token */
@ -38,9 +31,6 @@ export type WebhookMethod = (typeof WEBHOOK_METHODS)[number];
export type WebhookMimeType = (typeof WEBHOOK_MIME_TYPES)[number];
export type WebhookColorMode = (typeof WEBHOOK_COLOR_MODES)[number];
/**
* @additionalProperties false
*/
export interface WebhookConfig extends NotificationConfig {
provider: "webhook";
/**

View file

@ -1,9 +1,6 @@
import { URI, URL } from "../types";
import { GotifyConfig, WebhookConfig } from "./notification";
/**
* @additionalProperties false
*/
export type Providers = {
/** List of route definition files to include
*

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"definitions": {
"CIDR": {
"anyOf": [
@ -30,126 +29,320 @@
}
]
},
"Partial<CIDRWhitelist>": {
"properties": {
"allow": {
"items": {
"$ref": "#/definitions/CIDR"
"MiddlewareComposeMap": {
"anyOf": [
{
"additionalProperties": false,
"properties": {
"use": {
"enum": [
"CustomErrorPage",
"ErrorPage",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page"
],
"type": "string"
}
},
"type": "array"
},
"message": {
"default": "IP not allowed",
"description": "Error message when blocked",
"type": "string"
},
"status_code": {
"$ref": "#/definitions/StatusCode",
"default": 403,
"description": "HTTP status code when blocked"
}
},
"type": "object"
},
"Partial<CloudflareRealIP>": {
"properties": {
"recursive": {
"default": false,
"description": "Recursively resolve the IP",
"type": "boolean"
}
},
"type": "object"
},
"Partial<ModifyRequest>": {
"properties": {
"add_headers": {
"additionalProperties": {
"type": "string"
},
"description": "Add HTTP headers",
"required": [
"use"
],
"type": "object"
},
"hide_headers": {
"description": "Hide HTTP headers",
"items": {
"type": "string"
{
"additionalProperties": false,
"properties": {
"use": {
"enum": [
"RedirectHTTP",
"redirectHTTP",
"redirect_http"
],
"type": "string"
}
},
"type": "array"
"required": [
"use"
],
"type": "object"
},
"set_headers": {
"additionalProperties": {
"type": "string"
{
"additionalProperties": false,
"properties": {
"use": {
"enum": [
"SetXForwarded",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"description": "Set HTTP headers",
"required": [
"use"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"use": {
"enum": [
"HideXForwarded",
"hideXForwarded",
"hide_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"allow": {
"items": {
"$ref": "#/definitions/CIDR"
},
"type": "array"
},
"message": {
"default": "IP not allowed",
"description": "Error message when blocked",
"type": "string"
},
"status": {
"$ref": "#/definitions/StatusCode",
"default": 403,
"description": "HTTP status code when blocked (alias of status_code)"
},
"status_code": {
"$ref": "#/definitions/StatusCode",
"default": 403,
"description": "HTTP status code when blocked"
},
"use": {
"enum": [
"CIDRWhitelist",
"cidrWhitelist",
"cidr_whitelist"
],
"type": "string"
}
},
"required": [
"allow",
"use"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"recursive": {
"default": false,
"description": "Recursively resolve the IP",
"type": "boolean"
},
"use": {
"enum": [
"cloudflareRealIp",
"cloudflare_real_ip"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"add_headers": {
"additionalProperties": {
"type": "string"
},
"description": "Add HTTP headers",
"type": "object"
},
"hide_headers": {
"description": "Hide HTTP headers",
"items": {
"type": "string"
},
"type": "array"
},
"set_headers": {
"additionalProperties": {
"type": "string"
},
"description": "Set HTTP headers",
"type": "object"
},
"use": {
"enum": [
"ModifyRequest",
"Request",
"modifyRequest",
"modify_request",
"request"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"add_headers": {
"additionalProperties": {
"type": "string"
},
"description": "Add HTTP headers",
"type": "object"
},
"hide_headers": {
"description": "Hide HTTP headers",
"items": {
"type": "string"
},
"type": "array"
},
"set_headers": {
"additionalProperties": {
"type": "string"
},
"description": "Set HTTP headers",
"type": "object"
},
"use": {
"enum": [
"ModifyResponse",
"Response",
"modifyResponse",
"modify_response",
"response"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"allowed_groups": {
"description": "Allowed groups",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
},
"allowed_users": {
"description": "Allowed users",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
},
"use": {
"enum": [
"OIDC",
"oidc"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"average": {
"description": "Average number of requests allowed in a period",
"type": "number"
},
"burst": {
"description": "Maximum number of requests allowed in a period",
"type": "number"
},
"period": {
"default": "1s",
"description": "Duration of the rate limit",
"pattern": "^([0-9]+(ms|s|m|h))+$",
"type": "string"
},
"use": {
"enum": [
"RateLimit",
"rateLimit",
"rate_limit"
],
"type": "string"
}
},
"required": [
"average",
"burst",
"use"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"from": {
"items": {
"$ref": "#/definitions/CIDR"
},
"type": "array"
},
"header": {
"default": "X-Real-IP",
"description": "Header to get the client IP from",
"pattern": "^[a-zA-Z0-9\\-]+$",
"type": "string"
},
"recursive": {
"default": false,
"description": "Recursive resolve the IP",
"type": "boolean"
},
"use": {
"enum": [
"RealIP",
"realIP",
"real_ip"
],
"type": "string"
}
},
"required": [
"from",
"use"
],
"type": "object"
}
},
"type": "object"
},
"Partial<Null>": {
"type": "object"
},
"Partial<OIDC>": {
"properties": {
"allowed_groups": {
"description": "Allowed groups",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
},
"allowed_users": {
"description": "Allowed users",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
}
},
"type": "object"
},
"Partial<RateLimit>": {
"properties": {
"average": {
"description": "Average number of requests allowed in a period",
"type": "number"
},
"burst": {
"description": "Maximum number of requests allowed in a period",
"type": "number"
},
"period": {
"default": "1s",
"description": "Duration of the rate limit",
"pattern": "^([0-9]+(ms|s|m|h))+$",
"type": "string"
}
},
"type": "object"
},
"Partial<RealIP>": {
"properties": {
"from": {
"items": {
"$ref": "#/definitions/CIDR"
},
"type": "array"
},
"header": {
"description": "Header to get the client IP from",
"pattern": "^[a-zA-Z0-9\\-]+$",
"type": "string"
},
"recursive": {
"default": false,
"description": "Recursive resolve the IP",
"type": "boolean"
}
},
"type": "object"
]
},
"StatusCode": {
"anyOf": [
@ -164,414 +357,7 @@
}
},
"items": {
"anyOf": [
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<Null>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<OIDC>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<ModifyRequest>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<RealIP>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<CloudflareRealIP>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<RateLimit>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<CIDRWhitelist>"
}
]
}
]
"$ref": "#/definitions/MiddlewareComposeMap"
},
"type": "array"
}

View file

@ -1,11 +1,3 @@
import { MiddlewaresMap } from "./middlewares";
import { MiddlewareComposeMap } from "./middlewares";
export type MiddlewareComposeConfigBase = {
use: keyof MiddlewaresMap;
};
/**
* @additionalProperties false
*/
export type MiddlewareComposeConfig = (MiddlewareComposeConfigBase &
Partial<MiddlewaresMap[keyof MiddlewaresMap]>)[];
export type MiddlewareCompose = MiddlewareComposeMap[];

View file

@ -1,58 +1,57 @@
import * as types from "../types";
/**
* @additionalProperties false
*/
export type MiddlewaresMap = {
redirect_http?: RedirectHTTP;
redirectHTTP?: RedirectHTTP;
RedirectHTTP?: RedirectHTTP;
oidc?: types.Nullable<OIDC>;
OIDC?: types.Nullable<OIDC>;
request?: ModifyRequest;
Request?: ModifyRequest;
modify_request?: ModifyRequest;
modifyRequest?: ModifyRequest;
ModifyRequest?: ModifyRequest;
response?: ModifyResponse;
Response?: ModifyResponse;
modify_response?: ModifyResponse;
modifyResponse?: ModifyResponse;
ModifyResponse?: ModifyResponse;
set_x_forwarded?: SetXForwarded;
setXForwarded?: SetXForwarded;
SetXForwarded?: SetXForwarded;
hide_x_forwarded?: HideXForwarded;
hideXForwarded?: HideXForwarded;
HideXForwarded?: HideXForwarded;
error_page?: CustomErrorPage;
errorPage?: CustomErrorPage;
custom_error_page?: CustomErrorPage;
customErrorPage?: CustomErrorPage;
CustomErrorPage?: CustomErrorPage;
real_ip?: RealIP;
realIP?: RealIP;
RealIP?: RealIP;
cloudflare_real_ip?: types.Nullable<CloudflareRealIP>;
cloudflareRealIP?: types.Nullable<CloudflareRealIP>;
CloudflareRealIP?: types.Nullable<CloudflareRealIP>;
rate_limit?: RateLimit;
rateLimit?: RateLimit;
RateLimit?: RateLimit;
cidr_whitelist?: CIDRWhitelist;
cidrWhitelist?: CIDRWhitelist;
CIDRWhitelist?: CIDRWhitelist;
export type MiddlewareComposeObjectRef = `${string}@file`;
export type KeyOptMapping<T extends { use: string }> = {
[key in T["use"]]: Omit<T, "use">;
} | { use: MiddlewareComposeObjectRef };
export type MiddlewaresMap = (
| KeyOptMapping<CustomErrorPage>
| KeyOptMapping<RedirectHTTP>
| KeyOptMapping<SetXForwarded>
| KeyOptMapping<HideXForwarded>
| KeyOptMapping<CIDRWhitelist>
| KeyOptMapping<CloudflareRealIP>
| KeyOptMapping<ModifyRequest>
| KeyOptMapping<ModifyResponse>
| KeyOptMapping<OIDC>
| KeyOptMapping<RateLimit>
| KeyOptMapping<RealIP>
| { [key in MiddlewareComposeObjectRef]: types.NullOrEmptyMap }
);
export type MiddlewareComposeMap = (
| CustomErrorPage
| RedirectHTTP
| SetXForwarded
| HideXForwarded
| CIDRWhitelist
| CloudflareRealIP
| ModifyRequest
| ModifyResponse
| OIDC
| RateLimit
| RealIP
);
export type CustomErrorPage = {
use: "error_page" | "errorPage" | "ErrorPage" | "custom_error_page" | "customErrorPage" | "CustomErrorPage";
};
export type CustomErrorPage = types.Null;
export type RedirectHTTP = types.Null;
export type SetXForwarded = types.Null;
export type HideXForwarded = types.Null;
export type RedirectHTTP = {
use: "redirect_http" | "redirectHTTP" | "RedirectHTTP";
};
export type SetXForwarded = {
use: "set_x_forwarded" | "setXForwarded" | "SetXForwarded";
};
export type HideXForwarded = {
use: "hide_x_forwarded" | "hideXForwarded" | "HideXForwarded";
};
/**
* @additionalProperties false
*/
export type CIDRWhitelist = {
use: "cidr_whitelist" | "cidrWhitelist" | "CIDRWhitelist";
/* Allowed CIDRs/IPs */
allow: types.CIDR[];
/** HTTP status code when blocked
@ -60,6 +59,11 @@ export type CIDRWhitelist = {
* @default 403
*/
status_code?: types.StatusCode;
/** HTTP status code when blocked (alias of status_code)
*
* @default 403
*/
status?: types.StatusCode;
/** Error message when blocked
*
* @default "IP not allowed"
@ -67,10 +71,8 @@ export type CIDRWhitelist = {
message?: string;
};
/**
* @additionalProperties false
*/
export type CloudflareRealIP = {
use: "cloudflare_real_ip" | "cloudflareRealIp" | "cloudflare_real_ip";
/** Recursively resolve the IP
*
* @default false
@ -78,10 +80,8 @@ export type CloudflareRealIP = {
recursive?: boolean;
};
/**
* @additionalProperties false
*/
export type ModifyRequest = {
use: "request" | "Request" | "modify_request" | "modifyRequest" | "ModifyRequest";
/** Set HTTP headers */
set_headers?: { [key: types.HTTPHeader]: string };
/** Add HTTP headers */
@ -90,15 +90,18 @@ export type ModifyRequest = {
hide_headers?: types.HTTPHeader[];
};
/**
* @additionalProperties false
*/
export type ModifyResponse = ModifyRequest;
export type ModifyResponse = {
use: "response" | "Response" | "modify_response" | "modifyResponse" | "ModifyResponse";
/** Set HTTP headers */
set_headers?: { [key: types.HTTPHeader]: string };
/** Add HTTP headers */
add_headers?: { [key: types.HTTPHeader]: string };
/** Hide HTTP headers */
hide_headers?: types.HTTPHeader[];
};
/**
* @additionalProperties false
*/
export type OIDC = {
use: "oidc" | "OIDC";
/** Allowed users
*
* @minItems 1
@ -111,10 +114,8 @@ export type OIDC = {
allowed_groups?: string[];
};
/**
* @additionalProperties false
*/
export type RateLimit = {
use: "rate_limit" | "rateLimit" | "RateLimit";
/** Average number of requests allowed in a period
*
* @min 1
@ -132,18 +133,17 @@ export type RateLimit = {
period?: types.Duration;
};
/**
* @additionalProperties false
*/
export type RealIP = {
use: "real_ip" | "realIP" | "RealIP";
/** Header to get the client IP from
*
* @default "X-Real-IP"
*/
header: types.HTTPHeader;
header?: types.HTTPHeader;
from: types.CIDR[];
/** Recursive resolve the IP
*
* @default false
*/
recursive: boolean;
recursive?: boolean;
};

View file

@ -14,12 +14,8 @@ export const STOP_SIGNALS = [
"HUP",
"QUIT",
] as const;
export type Signal = (typeof STOP_SIGNALS)[number];
/**
* @additionalProperties false
*/
export type IdleWatcherConfig = {
/* Idle timeout */
idle_timeout?: Duration;

View file

@ -5,12 +5,8 @@ export const LOAD_BALANCE_MODES = [
"least_conn",
"ip_hash",
] as const;
export type LoadBalanceMode = (typeof LOAD_BALANCE_MODES)[number];
/**
* @additionalProperties false
*/
export type LoadBalanceConfigBase = {
/** Alias (subdomain or FDN) of load-balancer
*
@ -25,33 +21,24 @@ export type LoadBalanceConfigBase = {
weight?: number;
};
/**
* @additionalProperties false
*/
export type LoadBalanceConfig = LoadBalanceConfigBase &
(
| {} // linking other routes
| RoundRobinLoadBalanceConfig
| LeastConnLoadBalanceConfig
| IPHashLoadBalanceConfig
);
/**
* @additionalProperties false
*/
export type IPHashLoadBalanceConfig = {
mode: "ip_hash";
/** Real IP config, header to get client IP from */
config: RealIP;
};
/**
* @additionalProperties false
*/
export type LeastConnLoadBalanceConfig = {
mode: "least_conn";
};
/**
* @additionalProperties false
*/
export type RoundRobinLoadBalanceConfig = {
mode: "round_robin";
};

View file

@ -16,9 +16,6 @@ export type Routes = {
[key: string]: Route;
};
/**
* @additionalProperties false
*/
export type ReverseProxyRoute = {
/** Alias (subdomain or FDN)
* @minLength 1
@ -67,9 +64,6 @@ export type ReverseProxyRoute = {
access_log?: AccessLogConfig;
};
/**
* @additionalProperties false
*/
export type StreamRoute = {
/** Alias (subdomain or FDN)
* @minLength 1

File diff suppressed because it is too large Load diff

View file

@ -3,6 +3,7 @@
*/
export interface Null {}
export type Nullable<T> = T | Null;
export type NullOrEmptyMap = {} | Null;
export const HTTP_METHODS = [
"GET",