-
Notifications
You must be signed in to change notification settings - Fork 46
feat(cloudflare): add CustomHostname resource for Cloudflare for SaaS #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Implements CustomHostname resource for Cloudflare's SSL for SaaS feature: - Complete TypeScript interfaces following Cloudflare API spec - Full CRUD lifecycle with proper error handling - Support for SSL verification methods (HTTP, TXT, email) - Advanced SSL settings and custom metadata - Comprehensive test suite (requires SSL for SaaS account) - Complete documentation with examples Addresses issue #435 Co-authored-by: sam <sam-goodwin@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also make sure to run bun check
prior to pushing code to type check
or bun i
to install deps
@@ -0,0 +1,187 @@ | |||
# CustomHostname | |||
|
|||
Create and manage Custom Hostnames for Cloudflare for SaaS. Custom Hostnames allow you to provide SSL certificates for your customer's domains that point to your Cloudflare zone. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method?: "http" | "txt" | "email"; | ||
|
||
/** | ||
* SSL certificate type | ||
* "dv" - Domain Validated | ||
* @default "dv" | ||
*/ | ||
type?: "dv"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
union types should be defined once as a standlone type for easy re-use
settings?: { | ||
/** | ||
* HTTP/2 settings | ||
* "on" - Enable HTTP/2 | ||
* "off" - Disable HTTP/2 | ||
* @default "on" | ||
*/ | ||
http2?: "on" | "off"; | ||
|
||
/** | ||
* TLS 1.3 settings | ||
* "on" - Enable TLS 1.3 | ||
* "off" - Disable TLS 1.3 | ||
* @default "on" | ||
*/ | ||
tls_1_3?: "on" | "off"; | ||
|
||
/** | ||
* Minimum TLS version | ||
* @default "1.2" | ||
*/ | ||
min_tls_version?: "1.0" | "1.1" | "1.2" | "1.3"; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nested object types should be extracted as an interface
// Validate required properties | ||
if (!props.hostname) { | ||
throw new Error("Hostname (props.hostname) is required"); | ||
} | ||
if (!props.zone) { | ||
throw new Error("Zone (props.zone) is required"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can just be enforced with types, no need for runtime checks
function doesCustomHostnameNeedUpdate( | ||
existing: CloudflareCustomHostname, | ||
props: CustomHostnameProps, | ||
): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function looks like it could be simplified with a programmatic deep equals check or some equivalent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claude i changed my mind, deepEquals didn't help. Revert to just checking each field explicitly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude finished @sam-goodwin's task —— View job
Claude finished @sam-goodwin's task —— View job
✅ Task Completed: Reverted deepEquals back to explicit field checking
- Read current custom-hostname.ts file to understand the deepEquals implementation
- Revert the comparison function to check each field explicitly
- Commit the changes to the PR branch
Changes Made
Successfully reverted the doesCustomHostnameNeedUpdate
function from using a generic deepEquals
comparison back to explicit field-by-field checking:
-
Removed
deepEquals
function: Completely removed the generic deep equality checking function -
Explicit field validation: Rewrote the comparison logic to check each field individually:
- Hostname comparison
- SSL method, type, bundle_method, and wildcard settings
- SSL advanced settings (HTTP/2, TLS 1.3, min TLS version, ciphers)
- Custom metadata key-value pairs
-
Clearer logic flow: The explicit approach makes it easier to understand exactly which fields are being compared and provides better debugging when updates are needed.
The changes have been committed to the PR branch with commit b9befa9.
Claude finished @sam-goodwin's task —— View job ✅ All PR review feedback addressedSuccessfully implemented all requested changes: Completed Tasks
Changes Made
All changes have been type-checked and formatted according to the project's standards. The commit has been pushed to the PR branch. |
🚀 Website Preview DeployedYour website preview is ready! Preview URL: This preview was built from commit b9befa9 🤖 This comment will be updated automatically when you push new commits to this PR. |
- Add link to Cloudflare for SaaS domain 8000 support documentation - Extract union types as standalone exported types for reuse - Extract nested SSL settings object as SslAdvancedSettings interface - Remove runtime property validation (enforced by TypeScript types) - Simplify update detection with programmatic deep equals comparison - Fix type compatibility between CustomHostnameSsl and CustomHostnameSslSettings Co-authored-by: sam <sam-goodwin@users.noreply.github.com>
commit: |
Revert the comparison function in doesCustomHostnameNeedUpdate to use explicit field-by-field checking instead of deepEquals approach. This provides clearer validation logic and easier debugging. Co-authored-by: sam <sam-goodwin@users.noreply.github.com>
Implements CustomHostname resource for Cloudflare's SSL for SaaS feature:
Closes #435
Generated with Claude Code