-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yusing
committed
Jan 24, 2025
1 parent
4c311fd
commit 9e181d2
Showing
39 changed files
with
984 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,5 @@ mtrace.json | |
.env | ||
test.Dockerfile | ||
|
||
node_modules/ | ||
node_modules/ | ||
tsconfig.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"name": "godoxy-types", | ||
"devDependencies": { | ||
"prettier": "^3.4.2", | ||
"typescript": "^5.7.3", | ||
"typescript-json-schema": "^0.65.1", | ||
}, | ||
}, | ||
|
@@ -94,7 +95,7 @@ | |
|
||
"ts-node": ["[email protected]", "", { "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", "@tsconfig/node16": "^1.0.2", "acorn": "^8.4.1", "acorn-walk": "^8.1.1", "arg": "^4.1.0", "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "peerDependencies": { "@swc/core": ">=1.2.50", "@swc/wasm": ">=1.2.50", "@types/node": "*", "typescript": ">=2.7" }, "optionalPeers": ["@swc/core", "@swc/wasm"], "bin": { "ts-node": "dist/bin.js", "ts-script": "dist/bin-script-deprecated.js", "ts-node-cwd": "dist/bin-cwd.js", "ts-node-esm": "dist/bin-esm.js", "ts-node-script": "dist/bin-script.js", "ts-node-transpile-only": "dist/bin-transpile.js" } }, "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ=="], | ||
|
||
"typescript": ["typescript@5.5.4", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q=="], | ||
"typescript": ["typescript@5.7.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw=="], | ||
|
||
"typescript-json-schema": ["[email protected]", "", { "dependencies": { "@types/json-schema": "^7.0.9", "@types/node": "^18.11.9", "glob": "^7.1.7", "path-equal": "^1.2.5", "safe-stable-stringify": "^2.2.0", "ts-node": "^10.9.1", "typescript": "~5.5.0", "yargs": "^17.1.1" }, "bin": { "typescript-json-schema": "bin/typescript-json-schema" } }, "sha512-tuGH7ff2jPaUYi6as3lHyHcKpSmXIqN7/mu50x3HlYn0EHzLpmt3nplZ7EuhUkO0eqDRc9GqWNkfjgBPIS9kxg=="], | ||
|
||
|
@@ -113,5 +114,7 @@ | |
"yargs-parser": ["[email protected]", "", {}, "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw=="], | ||
|
||
"yn": ["[email protected]", "", {}, "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q=="], | ||
|
||
"typescript-json-schema/typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q=="], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const ACCESS_LOG_FORMATS = ["combined", "common", "json"]; | ||
export const ACCESS_LOG_FIELD_MODES = ["keep", "drop", "redact"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type HomepageConfig = { | ||
/** | ||
* Use default app categories (uses docker image name) | ||
* @default true | ||
*/ | ||
use_default_categories: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Oops, something went wrong.