-
-
Save helloimalastair/a431840311f78a104e03bce945ecbd8c to your computer and use it in GitHub Desktop.
Proposal for a Unified Cloudflare Pages Configuration file.
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
export { defineConfig }; | |
function defineConfig(config: PagesConfig): config { | |
return config; | |
} | |
declare interface PagesConfig { | |
name: string, | |
account_id?: string, | |
global: PagesEnvBoundConfig, | |
environments?: { | |
[key: string]: PagesEnvBoundConfig | |
} | |
} | |
declare interface PagesEnvBoundConfig { | |
pages_dev: boolean = true, | |
out_dir: string, | |
commands?: { | |
install?: string | |
build?: string | |
}, | |
custom_domains?: string[], | |
runtimes?: PagesRuntimes, | |
tools?: ToolOptions, | |
functions?: PagesFunctionsConfig, | |
headers?: { | |
[key: RegExp]: HeadersInit | |
}, | |
redirects?: { | |
[key: RegExp]: { | |
url: string, | |
code: number | |
} | |
} | |
} | |
declare interface PagesRuntimes { | |
[name: RuntimeOptions]: string | |
} | |
declare enum RuntimeOptions { | |
"Clojure", | |
"Elixir", | |
"Erlang", | |
"Go", | |
"Java", | |
"Node.js", | |
"PHP", | |
"Python", | |
"Ruby", | |
"Swift", | |
".NET" | |
} | |
declare enum ToolOptions { | |
"Boot", | |
"Cask", | |
"Composer", | |
"Doxygen", | |
"Emacs", | |
"Gutenberg", | |
"Hugo Extended", | |
"GNU Make", | |
"Image Magick", | |
"jq", | |
"Leiningen", | |
"OptiPNG", | |
"NPM", | |
"pip", | |
"Pipenv", | |
'sqlite3', | |
"Yarn", | |
"PnPM", | |
"wrangler2", | |
"Zola" | |
} | |
declare interface PagesFunctionsConfig { | |
routes?: { | |
include?: RegExp[], | |
exclude?: RegExp[] | |
}, | |
bindings?: PagesBindings[], | |
triggers?: string[], | |
node_compat: boolean = false, | |
compatibility_date?: string, | |
compatibility_flags?: string[] | |
} | |
declare type PagesBindings = DurableObjectBinding | KVBinding | ServiceBinding; | |
declare interface DurableObjectBinding { | |
name: string, | |
class_name: string, | |
script_name?: string | |
} | |
declare interface KVBinding { | |
name: string, | |
id: string | |
} | |
declare interface ServiceBinding { | |
binding: string, | |
service: string, | |
environment?: string | |
} | |
declare interface R2Binding { | |
binding: string, | |
bucket: string | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment