mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
fix npm package
This commit is contained in:
49
schemas/config/access_log.d.ts
vendored
Normal file
49
schemas/config/access_log.d.ts
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { CIDR, HTTPHeader, HTTPMethod, StatusCodeRange, URI } from "../types";
|
||||
export declare const ACCESS_LOG_FORMATS: readonly ["combined", "common", "json"];
|
||||
export type AccessLogFormat = (typeof ACCESS_LOG_FORMATS)[number];
|
||||
export type AccessLogConfig = {
|
||||
/**
|
||||
* The size of the buffer.
|
||||
*
|
||||
* @minimum 0
|
||||
* @default 65536
|
||||
* @TJS-type integer
|
||||
*/
|
||||
buffer_size?: number;
|
||||
/** The format of the access log.
|
||||
*
|
||||
* @default "combined"
|
||||
*/
|
||||
format?: AccessLogFormat;
|
||||
path: URI;
|
||||
filters?: AccessLogFilters;
|
||||
fields?: AccessLogFields;
|
||||
};
|
||||
export type AccessLogFilter<T> = {
|
||||
/** Whether the filter is negative.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
negative?: boolean;
|
||||
values: T[];
|
||||
};
|
||||
export type AccessLogFilters = {
|
||||
status_code?: AccessLogFilter<StatusCodeRange>;
|
||||
method?: AccessLogFilter<HTTPMethod>;
|
||||
host?: AccessLogFilter<string>;
|
||||
headers?: AccessLogFilter<HTTPHeader>;
|
||||
cidr?: AccessLogFilter<CIDR>;
|
||||
};
|
||||
export declare const ACCESS_LOG_FIELD_MODES: readonly ["keep", "drop", "redact"];
|
||||
export type AccessLogFieldMode = (typeof ACCESS_LOG_FIELD_MODES)[number];
|
||||
export type AccessLogField = {
|
||||
default?: AccessLogFieldMode;
|
||||
config: {
|
||||
[key: string]: AccessLogFieldMode;
|
||||
};
|
||||
};
|
||||
export type AccessLogFields = {
|
||||
header?: AccessLogField;
|
||||
query?: AccessLogField;
|
||||
cookie?: AccessLogField;
|
||||
};
|
||||
2
schemas/config/access_log.js
Normal file
2
schemas/config/access_log.js
Normal file
@@ -0,0 +1,2 @@
|
||||
export const ACCESS_LOG_FORMATS = ["combined", "common", "json"];
|
||||
export const ACCESS_LOG_FIELD_MODES = ["keep", "drop", "redact"];
|
||||
56
schemas/config/autocert.d.ts
vendored
Normal file
56
schemas/config/autocert.d.ts
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import { DomainOrWildcards as DomainsOrWildcards, Email } from "../types";
|
||||
export declare const AUTOCERT_PROVIDERS: readonly ["local", "cloudflare", "clouddns", "duckdns", "ovh"];
|
||||
export type AutocertProvider = (typeof AUTOCERT_PROVIDERS)[number];
|
||||
export type AutocertConfig = LocalOptions | CloudflareOptions | CloudDNSOptions | DuckDNSOptions | OVHOptionsWithAppKey | OVHOptionsWithOAuth2Config;
|
||||
export interface AutocertConfigBase {
|
||||
email: Email;
|
||||
domains: DomainsOrWildcards;
|
||||
cert_path?: string;
|
||||
key_path?: string;
|
||||
}
|
||||
export interface LocalOptions extends AutocertConfigBase {
|
||||
provider: "local";
|
||||
}
|
||||
export interface CloudflareOptions extends AutocertConfigBase {
|
||||
provider: "cloudflare";
|
||||
options: {
|
||||
auth_token: string;
|
||||
};
|
||||
}
|
||||
export interface CloudDNSOptions extends AutocertConfigBase {
|
||||
provider: "clouddns";
|
||||
options: {
|
||||
client_id: string;
|
||||
email: Email;
|
||||
password: string;
|
||||
};
|
||||
}
|
||||
export interface DuckDNSOptions extends AutocertConfigBase {
|
||||
provider: "duckdns";
|
||||
options: {
|
||||
token: string;
|
||||
};
|
||||
}
|
||||
export declare const OVH_ENDPOINTS: readonly ["ovh-eu", "ovh-ca", "ovh-us", "kimsufi-eu", "kimsufi-ca", "soyoustart-eu", "soyoustart-ca"];
|
||||
export type OVHEndpoint = (typeof OVH_ENDPOINTS)[number];
|
||||
export interface OVHOptionsWithAppKey extends AutocertConfigBase {
|
||||
provider: "ovh";
|
||||
options: {
|
||||
application_secret: string;
|
||||
consumer_key: string;
|
||||
api_endpoint?: OVHEndpoint;
|
||||
application_key: string;
|
||||
};
|
||||
}
|
||||
export interface OVHOptionsWithOAuth2Config extends AutocertConfigBase {
|
||||
provider: "ovh";
|
||||
options: {
|
||||
application_secret: string;
|
||||
consumer_key: string;
|
||||
api_endpoint?: OVHEndpoint;
|
||||
oauth2_config: {
|
||||
client_id: string;
|
||||
client_secret: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
16
schemas/config/autocert.js
Normal file
16
schemas/config/autocert.js
Normal file
@@ -0,0 +1,16 @@
|
||||
export const AUTOCERT_PROVIDERS = [
|
||||
"local",
|
||||
"cloudflare",
|
||||
"clouddns",
|
||||
"duckdns",
|
||||
"ovh",
|
||||
];
|
||||
export const OVH_ENDPOINTS = [
|
||||
"ovh-eu",
|
||||
"ovh-ca",
|
||||
"ovh-us",
|
||||
"kimsufi-eu",
|
||||
"kimsufi-ca",
|
||||
"soyoustart-eu",
|
||||
"soyoustart-ca",
|
||||
];
|
||||
54
schemas/config/config.d.ts
vendored
Normal file
54
schemas/config/config.d.ts
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import { DomainNames } from "../types";
|
||||
import { AutocertConfig } from "./autocert";
|
||||
import { EntrypointConfig } from "./entrypoint";
|
||||
import { HomepageConfig } from "./homepage";
|
||||
import { Providers } from "./providers";
|
||||
export type Config = {
|
||||
/** Optional autocert configuration
|
||||
*
|
||||
* @examples require(".").autocertExamples
|
||||
*/
|
||||
autocert?: AutocertConfig;
|
||||
entrypoint?: EntrypointConfig;
|
||||
providers: Providers;
|
||||
/** Optional list of domains to match
|
||||
*
|
||||
* @minItems 1
|
||||
* @examples require(".").matchDomainsExamples
|
||||
*/
|
||||
match_domains?: DomainNames;
|
||||
homepage?: HomepageConfig;
|
||||
/**
|
||||
* Optional timeout before shutdown
|
||||
* @default 3
|
||||
* @minimum 1
|
||||
*/
|
||||
timeout_shutdown?: number;
|
||||
};
|
||||
export declare const autocertExamples: ({
|
||||
provider: string;
|
||||
email?: undefined;
|
||||
domains?: undefined;
|
||||
options?: undefined;
|
||||
} | {
|
||||
provider: string;
|
||||
email: string;
|
||||
domains: string[];
|
||||
options: {
|
||||
auth_token: string;
|
||||
client_id?: undefined;
|
||||
email?: undefined;
|
||||
password?: undefined;
|
||||
};
|
||||
} | {
|
||||
provider: string;
|
||||
email: string;
|
||||
domains: string[];
|
||||
options: {
|
||||
client_id: string;
|
||||
email: string;
|
||||
password: string;
|
||||
auth_token?: undefined;
|
||||
};
|
||||
})[];
|
||||
export declare const matchDomainsExamples: readonly ["example.com", "*.example.com"];
|
||||
20
schemas/config/config.js
Normal file
20
schemas/config/config.js
Normal file
@@ -0,0 +1,20 @@
|
||||
export const autocertExamples = [
|
||||
{ provider: "local" },
|
||||
{
|
||||
provider: "cloudflare",
|
||||
email: "abc@gmail",
|
||||
domains: ["example.com"],
|
||||
options: { auth_token: "c1234565789-abcdefghijklmnopqrst" },
|
||||
},
|
||||
{
|
||||
provider: "clouddns",
|
||||
email: "abc@gmail",
|
||||
domains: ["example.com"],
|
||||
options: {
|
||||
client_id: "c1234565789",
|
||||
email: "abc@gmail",
|
||||
password: "password",
|
||||
},
|
||||
},
|
||||
];
|
||||
export const matchDomainsExamples = ["example.com", "*.example.com"];
|
||||
39
schemas/config/entrypoint.d.ts
vendored
Normal file
39
schemas/config/entrypoint.d.ts
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { MiddlewareCompose } from "../middlewares/middleware_compose";
|
||||
import { AccessLogConfig } from "./access_log";
|
||||
export type EntrypointConfig = {
|
||||
/** Entrypoint middleware configuration
|
||||
*
|
||||
* @examples require(".").middlewaresExamples
|
||||
*/
|
||||
middlewares: MiddlewareCompose;
|
||||
/** Entrypoint access log configuration
|
||||
*
|
||||
* @examples require(".").accessLogExamples
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
};
|
||||
export declare const accessLogExamples: readonly [{
|
||||
readonly path: "/var/log/access.log";
|
||||
readonly format: "combined";
|
||||
readonly filters: {
|
||||
readonly status_codes: {
|
||||
readonly values: readonly ["200-299"];
|
||||
};
|
||||
};
|
||||
readonly fields: {
|
||||
readonly headers: {
|
||||
readonly default: "keep";
|
||||
readonly config: {
|
||||
readonly foo: "redact";
|
||||
};
|
||||
};
|
||||
};
|
||||
}];
|
||||
export declare const middlewaresExamples: readonly [{
|
||||
readonly use: "RedirectHTTP";
|
||||
}, {
|
||||
readonly use: "CIDRWhitelist";
|
||||
readonly allow: readonly ["127.0.0.1", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"];
|
||||
readonly status: 403;
|
||||
readonly message: "Forbidden";
|
||||
}];
|
||||
30
schemas/config/entrypoint.js
Normal file
30
schemas/config/entrypoint.js
Normal file
@@ -0,0 +1,30 @@
|
||||
export const accessLogExamples = [
|
||||
{
|
||||
path: "/var/log/access.log",
|
||||
format: "combined",
|
||||
filters: {
|
||||
status_codes: {
|
||||
values: ["200-299"],
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
headers: {
|
||||
default: "keep",
|
||||
config: {
|
||||
foo: "redact",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
export const middlewaresExamples = [
|
||||
{
|
||||
use: "RedirectHTTP",
|
||||
},
|
||||
{
|
||||
use: "CIDRWhitelist",
|
||||
allow: ["127.0.0.1", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"],
|
||||
status: 403,
|
||||
message: "Forbidden",
|
||||
},
|
||||
];
|
||||
7
schemas/config/homepage.d.ts
vendored
Normal file
7
schemas/config/homepage.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export type HomepageConfig = {
|
||||
/**
|
||||
* Use default app categories (uses docker image name)
|
||||
* @default true
|
||||
*/
|
||||
use_default_categories: boolean;
|
||||
};
|
||||
1
schemas/config/homepage.js
Normal file
1
schemas/config/homepage.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
52
schemas/config/notification.d.ts
vendored
Normal file
52
schemas/config/notification.d.ts
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { URL } from "../types";
|
||||
export declare const NOTIFICATION_PROVIDERS: readonly ["webhook", "gotify"];
|
||||
export type NotificationProvider = (typeof NOTIFICATION_PROVIDERS)[number];
|
||||
export type NotificationConfig = {
|
||||
name: string;
|
||||
url: URL;
|
||||
};
|
||||
export interface GotifyConfig extends NotificationConfig {
|
||||
provider: "gotify";
|
||||
token: string;
|
||||
}
|
||||
export declare const WEBHOOK_TEMPLATES: readonly ["discord"];
|
||||
export declare const WEBHOOK_METHODS: readonly ["POST", "GET", "PUT"];
|
||||
export declare const WEBHOOK_MIME_TYPES: readonly ["application/json", "application/x-www-form-urlencoded", "text/plain"];
|
||||
export declare const WEBHOOK_COLOR_MODES: readonly ["hex", "dec"];
|
||||
export type WebhookTemplate = (typeof WEBHOOK_TEMPLATES)[number];
|
||||
export type WebhookMethod = (typeof WEBHOOK_METHODS)[number];
|
||||
export type WebhookMimeType = (typeof WEBHOOK_MIME_TYPES)[number];
|
||||
export type WebhookColorMode = (typeof WEBHOOK_COLOR_MODES)[number];
|
||||
export interface WebhookConfig extends NotificationConfig {
|
||||
provider: "webhook";
|
||||
/**
|
||||
* Webhook template
|
||||
*
|
||||
* @default "discord"
|
||||
*/
|
||||
template?: WebhookTemplate;
|
||||
token?: string;
|
||||
/**
|
||||
* Webhook message (usally JSON),
|
||||
* required when template is not defined
|
||||
*/
|
||||
payload?: string;
|
||||
/**
|
||||
* Webhook method
|
||||
*
|
||||
* @default "POST"
|
||||
*/
|
||||
method?: WebhookMethod;
|
||||
/**
|
||||
* Webhook mime type
|
||||
*
|
||||
* @default "application/json"
|
||||
*/
|
||||
mime_type?: WebhookMimeType;
|
||||
/**
|
||||
* Webhook color mode
|
||||
*
|
||||
* @default "hex"
|
||||
*/
|
||||
color_mode?: WebhookColorMode;
|
||||
}
|
||||
9
schemas/config/notification.js
Normal file
9
schemas/config/notification.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export const NOTIFICATION_PROVIDERS = ["webhook", "gotify"];
|
||||
export const WEBHOOK_TEMPLATES = ["discord"];
|
||||
export const WEBHOOK_METHODS = ["POST", "GET", "PUT"];
|
||||
export const WEBHOOK_MIME_TYPES = [
|
||||
"application/json",
|
||||
"application/x-www-form-urlencoded",
|
||||
"text/plain",
|
||||
];
|
||||
export const WEBHOOK_COLOR_MODES = ["hex", "dec"];
|
||||
44
schemas/config/providers.d.ts
vendored
Normal file
44
schemas/config/providers.d.ts
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { URI, URL } from "../types";
|
||||
import { GotifyConfig, WebhookConfig } from "./notification";
|
||||
export type Providers = {
|
||||
/** List of route definition files to include
|
||||
*
|
||||
* @minItems 1
|
||||
* @examples require(".").includeExamples
|
||||
* @items.pattern ^[\w\d\-_]+\.(yaml|yml)$
|
||||
*/
|
||||
include?: URI[];
|
||||
/** Name-value mapping of docker hosts to retrieve routes from
|
||||
*
|
||||
* @minProperties 1
|
||||
* @examples require(".").dockerExamples
|
||||
*/
|
||||
docker?: {
|
||||
[name: string]: URL | "$DOCKER_HOST";
|
||||
};
|
||||
/** List of notification providers
|
||||
*
|
||||
* @minItems 1
|
||||
* @examples require(".").notificationExamples
|
||||
*/
|
||||
notification?: (WebhookConfig | GotifyConfig)[];
|
||||
};
|
||||
export declare const includeExamples: readonly ["file1.yml", "file2.yml"];
|
||||
export declare const dockerExamples: readonly [{
|
||||
readonly local: "$DOCKER_HOST";
|
||||
}, {
|
||||
readonly remote: "tcp://10.0.2.1:2375";
|
||||
}, {
|
||||
readonly remote2: "ssh://root:1234@10.0.2.2";
|
||||
}];
|
||||
export declare const notificationExamples: readonly [{
|
||||
readonly name: "gotify";
|
||||
readonly provider: "gotify";
|
||||
readonly url: "https://gotify.domain.tld";
|
||||
readonly token: "abcd";
|
||||
}, {
|
||||
readonly name: "discord";
|
||||
readonly provider: "webhook";
|
||||
readonly template: "discord";
|
||||
readonly url: "https://discord.com/api/webhooks/1234/abcd";
|
||||
}];
|
||||
20
schemas/config/providers.js
Normal file
20
schemas/config/providers.js
Normal file
@@ -0,0 +1,20 @@
|
||||
export const includeExamples = ["file1.yml", "file2.yml"];
|
||||
export const dockerExamples = [
|
||||
{ local: "$DOCKER_HOST" },
|
||||
{ remote: "tcp://10.0.2.1:2375" },
|
||||
{ remote2: "ssh://root:1234@10.0.2.2" },
|
||||
];
|
||||
export const notificationExamples = [
|
||||
{
|
||||
name: "gotify",
|
||||
provider: "gotify",
|
||||
url: "https://gotify.domain.tld",
|
||||
token: "abcd",
|
||||
},
|
||||
{
|
||||
name: "discord",
|
||||
provider: "webhook",
|
||||
template: "discord",
|
||||
url: "https://discord.com/api/webhooks/1234/abcd",
|
||||
},
|
||||
];
|
||||
5
schemas/docker.d.ts
vendored
Normal file
5
schemas/docker.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { IdleWatcherConfig } from "./providers/idlewatcher";
|
||||
import { Route } from "./providers/routes";
|
||||
export type DockerRoutes = {
|
||||
[key: string]: Route & IdleWatcherConfig;
|
||||
};
|
||||
1
schemas/docker.js
Normal file
1
schemas/docker.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
15
schemas/index.d.ts
vendored
Normal file
15
schemas/index.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as AccessLog from "./config/access_log";
|
||||
import * as Autocert from "./config/autocert";
|
||||
import * as Config from "./config/config";
|
||||
import * as Entrypoint from "./config/entrypoint";
|
||||
import * as Notification from "./config/notification";
|
||||
import * as Providers from "./config/providers";
|
||||
import * as MiddlewareCompose from "./middlewares/middleware_compose";
|
||||
import * as Middlewares from "./middlewares/middlewares";
|
||||
import * as Healthcheck from "./providers/healthcheck";
|
||||
import * as Homepage from "./providers/homepage";
|
||||
import * as IdleWatcher from "./providers/idlewatcher";
|
||||
import * as LoadBalance from "./providers/loadbalance";
|
||||
import * as Routes from "./providers/routes";
|
||||
import * as GoDoxy from "./types";
|
||||
export { AccessLog, Autocert, Config, Entrypoint, GoDoxy, Healthcheck, Homepage, IdleWatcher, LoadBalance, MiddlewareCompose, Middlewares, Notification, Providers, Routes, };
|
||||
15
schemas/index.js
Normal file
15
schemas/index.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as AccessLog from "./config/access_log";
|
||||
import * as Autocert from "./config/autocert";
|
||||
import * as Config from "./config/config";
|
||||
import * as Entrypoint from "./config/entrypoint";
|
||||
import * as Notification from "./config/notification";
|
||||
import * as Providers from "./config/providers";
|
||||
import * as MiddlewareCompose from "./middlewares/middleware_compose";
|
||||
import * as Middlewares from "./middlewares/middlewares";
|
||||
import * as Healthcheck from "./providers/healthcheck";
|
||||
import * as Homepage from "./providers/homepage";
|
||||
import * as IdleWatcher from "./providers/idlewatcher";
|
||||
import * as LoadBalance from "./providers/loadbalance";
|
||||
import * as Routes from "./providers/routes";
|
||||
import * as GoDoxy from "./types";
|
||||
export { AccessLog, Autocert, Config, Entrypoint, GoDoxy, Healthcheck, Homepage, IdleWatcher, LoadBalance, MiddlewareCompose, Middlewares, Notification, Providers, Routes, };
|
||||
34
schemas/index.ts
Normal file
34
schemas/index.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import * as AccessLog from "./config/access_log";
|
||||
import * as Autocert from "./config/autocert";
|
||||
import * as Config from "./config/config";
|
||||
import * as Entrypoint from "./config/entrypoint";
|
||||
import * as Notification from "./config/notification";
|
||||
import * as Providers from "./config/providers";
|
||||
|
||||
import * as MiddlewareCompose from "./middlewares/middleware_compose";
|
||||
import * as Middlewares from "./middlewares/middlewares";
|
||||
|
||||
import * as Healthcheck from "./providers/healthcheck";
|
||||
import * as Homepage from "./providers/homepage";
|
||||
import * as IdleWatcher from "./providers/idlewatcher";
|
||||
import * as LoadBalance from "./providers/loadbalance";
|
||||
import * as Routes from "./providers/routes";
|
||||
|
||||
import * as GoDoxy from "./types";
|
||||
|
||||
export {
|
||||
AccessLog,
|
||||
Autocert,
|
||||
Config,
|
||||
Entrypoint,
|
||||
GoDoxy,
|
||||
Healthcheck,
|
||||
Homepage,
|
||||
IdleWatcher,
|
||||
LoadBalance,
|
||||
MiddlewareCompose,
|
||||
Middlewares,
|
||||
Notification,
|
||||
Providers,
|
||||
Routes,
|
||||
};
|
||||
2
schemas/middlewares/middleware_compose.d.ts
vendored
Normal file
2
schemas/middlewares/middleware_compose.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { MiddlewareComposeMap } from "./middlewares";
|
||||
export type MiddlewareCompose = MiddlewareComposeMap[];
|
||||
1
schemas/middlewares/middleware_compose.js
Normal file
1
schemas/middlewares/middleware_compose.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
123
schemas/middlewares/middlewares.d.ts
vendored
Normal file
123
schemas/middlewares/middlewares.d.ts
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
import * as types from "../types";
|
||||
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 RedirectHTTP = {
|
||||
use: "redirect_http" | "redirectHTTP" | "RedirectHTTP";
|
||||
};
|
||||
export type SetXForwarded = {
|
||||
use: "set_x_forwarded" | "setXForwarded" | "SetXForwarded";
|
||||
};
|
||||
export type HideXForwarded = {
|
||||
use: "hide_x_forwarded" | "hideXForwarded" | "HideXForwarded";
|
||||
};
|
||||
export type CIDRWhitelist = {
|
||||
use: "cidr_whitelist" | "cidrWhitelist" | "CIDRWhitelist";
|
||||
allow: types.CIDR[];
|
||||
/** HTTP status code when blocked
|
||||
*
|
||||
* @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"
|
||||
*/
|
||||
message?: string;
|
||||
};
|
||||
export type CloudflareRealIP = {
|
||||
use: "cloudflare_real_ip" | "cloudflareRealIp" | "cloudflare_real_ip";
|
||||
/** Recursively resolve the IP
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
recursive?: boolean;
|
||||
};
|
||||
export type ModifyRequest = {
|
||||
use: "request" | "Request" | "modify_request" | "modifyRequest" | "ModifyRequest";
|
||||
/** 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[];
|
||||
};
|
||||
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[];
|
||||
};
|
||||
export type OIDC = {
|
||||
use: "oidc" | "OIDC";
|
||||
/** Allowed users
|
||||
*
|
||||
* @minItems 1
|
||||
*/
|
||||
allowed_users?: string[];
|
||||
/** Allowed groups
|
||||
*
|
||||
* @minItems 1
|
||||
*/
|
||||
allowed_groups?: string[];
|
||||
};
|
||||
export type RateLimit = {
|
||||
use: "rate_limit" | "rateLimit" | "RateLimit";
|
||||
/** Average number of requests allowed in a period
|
||||
*
|
||||
* @min 1
|
||||
*/
|
||||
average: number;
|
||||
/** Maximum number of requests allowed in a period
|
||||
*
|
||||
* @min 1
|
||||
*/
|
||||
burst: number;
|
||||
/** Duration of the rate limit
|
||||
*
|
||||
* @default 1s
|
||||
*/
|
||||
period?: types.Duration;
|
||||
};
|
||||
export type RealIP = {
|
||||
use: "real_ip" | "realIP" | "RealIP";
|
||||
/** Header to get the client IP from
|
||||
*
|
||||
* @default "X-Real-IP"
|
||||
*/
|
||||
header?: types.HTTPHeader;
|
||||
from: types.CIDR[];
|
||||
/** Recursive resolve the IP
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
recursive?: boolean;
|
||||
};
|
||||
1
schemas/middlewares/middlewares.js
Normal file
1
schemas/middlewares/middlewares.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
32
schemas/providers/healthcheck.d.ts
vendored
Normal file
32
schemas/providers/healthcheck.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Duration, URI } from "../types";
|
||||
/**
|
||||
* @additionalProperties false
|
||||
*/
|
||||
export type HealthcheckConfig = {
|
||||
/** Disable healthcheck
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disable?: boolean;
|
||||
/** Healthcheck path
|
||||
*
|
||||
* @default /
|
||||
*/
|
||||
path?: URI;
|
||||
/**
|
||||
* Use GET instead of HEAD
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
use_get?: boolean;
|
||||
/** Healthcheck interval
|
||||
*
|
||||
* @default 5s
|
||||
*/
|
||||
interval?: Duration;
|
||||
/** Healthcheck timeout
|
||||
*
|
||||
* @default 5s
|
||||
*/
|
||||
timeout?: Duration;
|
||||
};
|
||||
1
schemas/providers/healthcheck.js
Normal file
1
schemas/providers/healthcheck.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
22
schemas/providers/homepage.d.ts
vendored
Normal file
22
schemas/providers/homepage.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { URL } from "../types";
|
||||
/**
|
||||
* @additionalProperties false
|
||||
*/
|
||||
export type HomepageConfig = {
|
||||
/** Whether show in dashboard
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
show?: boolean;
|
||||
name?: string;
|
||||
icon?: URL | WalkxcodeIcon | ExternalIcon | TargetRelativeIconPath;
|
||||
description?: string;
|
||||
url?: URL;
|
||||
category?: string;
|
||||
widget_config?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
export type WalkxcodeIcon = `${"png" | "svg" | "webp"}/${string}/${string}.${string}`;
|
||||
export type ExternalIcon = `@${"selfhst" | "walkxcode"}/${string}.${string}`;
|
||||
export type TargetRelativeIconPath = `@target/${string}` | `/${string}`;
|
||||
1
schemas/providers/homepage.js
Normal file
1
schemas/providers/homepage.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
25
schemas/providers/idlewatcher.d.ts
vendored
Normal file
25
schemas/providers/idlewatcher.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Duration, URI } from "../types";
|
||||
export declare const STOP_METHODS: readonly ["pause", "stop", "kill"];
|
||||
export type StopMethod = (typeof STOP_METHODS)[number];
|
||||
export declare const STOP_SIGNALS: readonly ["", "SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT", "INT", "TERM", "HUP", "QUIT"];
|
||||
export type Signal = (typeof STOP_SIGNALS)[number];
|
||||
export type IdleWatcherConfig = {
|
||||
idle_timeout?: Duration;
|
||||
/** Wake timeout
|
||||
*
|
||||
* @default 30s
|
||||
*/
|
||||
wake_timeout?: Duration;
|
||||
/** Stop timeout
|
||||
*
|
||||
* @default 30s
|
||||
*/
|
||||
stop_timeout?: Duration;
|
||||
/** Stop method
|
||||
*
|
||||
* @default stop
|
||||
*/
|
||||
stop_method?: StopMethod;
|
||||
stop_signal?: Signal;
|
||||
start_endpoint?: URI;
|
||||
};
|
||||
12
schemas/providers/idlewatcher.js
Normal file
12
schemas/providers/idlewatcher.js
Normal file
@@ -0,0 +1,12 @@
|
||||
export const STOP_METHODS = ["pause", "stop", "kill"];
|
||||
export const STOP_SIGNALS = [
|
||||
"",
|
||||
"SIGINT",
|
||||
"SIGTERM",
|
||||
"SIGHUP",
|
||||
"SIGQUIT",
|
||||
"INT",
|
||||
"TERM",
|
||||
"HUP",
|
||||
"QUIT",
|
||||
];
|
||||
28
schemas/providers/loadbalance.d.ts
vendored
Normal file
28
schemas/providers/loadbalance.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { RealIP } from "../middlewares/middlewares";
|
||||
export declare const LOAD_BALANCE_MODES: readonly ["round_robin", "least_conn", "ip_hash"];
|
||||
export type LoadBalanceMode = (typeof LOAD_BALANCE_MODES)[number];
|
||||
export type LoadBalanceConfigBase = {
|
||||
/** Alias (subdomain or FDN) of load-balancer
|
||||
*
|
||||
* @minLength 1
|
||||
*/
|
||||
link: string;
|
||||
/** Load-balance weight (reserved for future use)
|
||||
*
|
||||
* @minimum 0
|
||||
* @maximum 100
|
||||
*/
|
||||
weight?: number;
|
||||
};
|
||||
export type LoadBalanceConfig = LoadBalanceConfigBase & ({} | RoundRobinLoadBalanceConfig | LeastConnLoadBalanceConfig | IPHashLoadBalanceConfig);
|
||||
export type IPHashLoadBalanceConfig = {
|
||||
mode: "ip_hash";
|
||||
/** Real IP config, header to get client IP from */
|
||||
config: RealIP;
|
||||
};
|
||||
export type LeastConnLoadBalanceConfig = {
|
||||
mode: "least_conn";
|
||||
};
|
||||
export type RoundRobinLoadBalanceConfig = {
|
||||
mode: "round_robin";
|
||||
};
|
||||
5
schemas/providers/loadbalance.js
Normal file
5
schemas/providers/loadbalance.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export const LOAD_BALANCE_MODES = [
|
||||
"round_robin",
|
||||
"least_conn",
|
||||
"ip_hash",
|
||||
];
|
||||
102
schemas/providers/routes.d.ts
vendored
Normal file
102
schemas/providers/routes.d.ts
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
import { AccessLogConfig } from "../config/access_log";
|
||||
import { accessLogExamples } from "../config/entrypoint";
|
||||
import { MiddlewaresMap } from "../middlewares/middlewares";
|
||||
import { Hostname, IPv4, IPv6, PathPattern, Port, StreamPort } from "../types";
|
||||
import { HealthcheckConfig } from "./healthcheck";
|
||||
import { HomepageConfig } from "./homepage";
|
||||
import { LoadBalanceConfig } from "./loadbalance";
|
||||
export declare const PROXY_SCHEMES: readonly ["http", "https"];
|
||||
export declare const STREAM_SCHEMES: readonly ["tcp", "udp"];
|
||||
export type ProxyScheme = (typeof PROXY_SCHEMES)[number];
|
||||
export type StreamScheme = (typeof STREAM_SCHEMES)[number];
|
||||
export type Route = ReverseProxyRoute | StreamRoute;
|
||||
export type Routes = {
|
||||
[key: string]: Route;
|
||||
};
|
||||
export type ReverseProxyRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
/** Proxy scheme
|
||||
*
|
||||
* @default http
|
||||
*/
|
||||
scheme?: ProxyScheme;
|
||||
/** Proxy host
|
||||
*
|
||||
* @default localhost
|
||||
*/
|
||||
host?: Hostname | IPv4 | IPv6;
|
||||
/** Proxy port
|
||||
*
|
||||
* @default 80
|
||||
*/
|
||||
port?: Port;
|
||||
/** Skip TLS verification
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
no_tls_verify?: boolean;
|
||||
/** Path patterns (only patterns that match will be proxied).
|
||||
*
|
||||
* See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux
|
||||
*/
|
||||
path_patterns?: PathPattern[];
|
||||
/** Healthcheck config */
|
||||
healthcheck?: HealthcheckConfig;
|
||||
/** Load balance config */
|
||||
load_balance?: LoadBalanceConfig;
|
||||
/** Middlewares */
|
||||
middlewares?: MiddlewaresMap;
|
||||
/** Homepage config
|
||||
*
|
||||
* @examples require(".").homepageExamples
|
||||
*/
|
||||
homepage?: HomepageConfig;
|
||||
/** Access log config
|
||||
*
|
||||
* @examples require(".").accessLogExamples
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
};
|
||||
export type StreamRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
/** Stream scheme
|
||||
*
|
||||
* @default tcp
|
||||
*/
|
||||
scheme: StreamScheme;
|
||||
/** Stream host
|
||||
*
|
||||
* @default localhost
|
||||
*/
|
||||
host?: Hostname | IPv4 | IPv6;
|
||||
port: StreamPort;
|
||||
/** Healthcheck config */
|
||||
healthcheck?: HealthcheckConfig;
|
||||
};
|
||||
export declare const homepageExamples: ({
|
||||
name: string;
|
||||
icon: string;
|
||||
category: string;
|
||||
} | {
|
||||
name: string;
|
||||
icon: string;
|
||||
category?: undefined;
|
||||
})[];
|
||||
export declare const loadBalanceExamples: ({
|
||||
link: string;
|
||||
mode: string;
|
||||
config?: undefined;
|
||||
} | {
|
||||
link: string;
|
||||
mode: string;
|
||||
config: {
|
||||
header: string;
|
||||
};
|
||||
})[];
|
||||
export { accessLogExamples };
|
||||
28
schemas/providers/routes.js
Normal file
28
schemas/providers/routes.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { accessLogExamples } from "../config/entrypoint";
|
||||
export const PROXY_SCHEMES = ["http", "https"];
|
||||
export const STREAM_SCHEMES = ["tcp", "udp"];
|
||||
export const homepageExamples = [
|
||||
{
|
||||
name: "Sonarr",
|
||||
icon: "png/sonarr.png",
|
||||
category: "Arr suite",
|
||||
},
|
||||
{
|
||||
name: "App",
|
||||
icon: "@target/favicon.ico",
|
||||
},
|
||||
];
|
||||
export const loadBalanceExamples = [
|
||||
{
|
||||
link: "flaresolverr",
|
||||
mode: "round_robin",
|
||||
},
|
||||
{
|
||||
link: "service.domain.com",
|
||||
mode: "ip_hash",
|
||||
config: {
|
||||
header: "X-Real-IP",
|
||||
},
|
||||
},
|
||||
];
|
||||
export { accessLogExamples };
|
||||
94
schemas/types.d.ts
vendored
Normal file
94
schemas/types.d.ts
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* @type "null"
|
||||
*/
|
||||
export interface Null {
|
||||
}
|
||||
export type Nullable<T> = T | Null;
|
||||
export type NullOrEmptyMap = {} | Null;
|
||||
export declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "CONNECT", "HEAD", "OPTIONS", "TRACE"];
|
||||
export type HTTPMethod = (typeof HTTP_METHODS)[number];
|
||||
/**
|
||||
* HTTP Header
|
||||
* @pattern ^[a-zA-Z0-9\-]+$
|
||||
* @type string
|
||||
*/
|
||||
export type HTTPHeader = string & {};
|
||||
/**
|
||||
* HTTP Query
|
||||
* @pattern ^[a-zA-Z0-9\-_]+$
|
||||
* @type string
|
||||
*/
|
||||
export type HTTPQuery = string & {};
|
||||
/**
|
||||
* HTTP Cookie
|
||||
* @pattern ^[a-zA-Z0-9\-_]+$
|
||||
* @type string
|
||||
*/
|
||||
export type HTTPCookie = string & {};
|
||||
export type StatusCode = number | `${number}`;
|
||||
export type StatusCodeRange = number | `${number}` | `${number}-${number}`;
|
||||
/**
|
||||
* @items.pattern ^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$
|
||||
*/
|
||||
export type DomainNames = string[];
|
||||
/**
|
||||
* @items.pattern ^(\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$
|
||||
*/
|
||||
export type DomainOrWildcards = string[];
|
||||
/**
|
||||
* @format hostname
|
||||
* @type string
|
||||
*/
|
||||
export type Hostname = string & {};
|
||||
/**
|
||||
* @format ipv4
|
||||
* @type string
|
||||
*/
|
||||
export type IPv4 = string & {};
|
||||
/**
|
||||
* @format ipv6
|
||||
* @type string
|
||||
*/
|
||||
export type IPv6 = string & {};
|
||||
export type CIDR = `${number}.${number}.${number}.${number}` | `${string}:${string}:${string}:${string}:${string}:${string}:${string}:${string}` | `${number}.${number}.${number}.${number}/${number}` | `::${number}` | `${string}::/${number}` | `${string}:${string}::/${number}`;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @maximum 65535
|
||||
*/
|
||||
export type Port = number | `${number}`;
|
||||
/**
|
||||
* @pattern ^\d+:\d+$
|
||||
* @type string
|
||||
*/
|
||||
export type StreamPort = string & {};
|
||||
/**
|
||||
* @format email
|
||||
* @type string
|
||||
*/
|
||||
export type Email = string & {};
|
||||
/**
|
||||
* @format uri
|
||||
* @type string
|
||||
*/
|
||||
export type URL = string & {};
|
||||
/**
|
||||
* @format uri-reference
|
||||
* @type string
|
||||
*/
|
||||
export type URI = string & {};
|
||||
/**
|
||||
* @pattern ^(?:([A-Z]+) )?(?:([a-zA-Z0-9.-]+)\\/)?(\\/[^\\s]*)$
|
||||
* @type string
|
||||
*/
|
||||
export type PathPattern = string & {};
|
||||
/**
|
||||
* @pattern ^([0-9]+(ms|s|m|h))+$
|
||||
* @type string
|
||||
*/
|
||||
export type Duration = string & {};
|
||||
/**
|
||||
* @format date-time
|
||||
* @type string
|
||||
*/
|
||||
export type DateTime = string & {};
|
||||
11
schemas/types.js
Normal file
11
schemas/types.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export const HTTP_METHODS = [
|
||||
"GET",
|
||||
"POST",
|
||||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"CONNECT",
|
||||
"HEAD",
|
||||
"OPTIONS",
|
||||
"TRACE",
|
||||
];
|
||||
Reference in New Issue
Block a user