Building the "shadcn/ui for Backend": A Contract-First Approach
说明与用途
Plughub CLI 用户面临 SMTP 被阻断的问题,但通过合同优先的设计,可以在不更改应用代码的情况下在 SMTP 和 HTTP 提供商之间切换。
问题
Users of the Plughub CLI may be blocked from using SMTP due to network restrictions, limiting email capability.
结果
The contract-first approach enables seamless provider swapping, allowing users to avoid transport lock-in and use alternative transports like HTTP over port 443.
工作流
- Define capability contract (e.g.,
sendEmail(input) -> result). - Import contract in application code.
- Implement provider (SMTP or Resend) that fulfills the contract.
- Swap provider by changing configuration; application code remains unchanged.
证据
I tried to send a real email, but my mobile carrier actively blocks outbound connections on port 587 (a common anti-spam measure).
I decided to build an HTTP-based provider (Resend) that sends emails via port 443.
When I swapped the SMTP provider for the Resend provider, the application code didn't change. It just kept calling email.sendEmail().
Using the AWS SDK v3, the s3 provider can connect to AWS, Cloudflare R2, or a local MinIO instance.
- 记录日期: 2026-10-24T09:11:08.531Z