Skip to content

Commit 3900330

Browse files
authored
feat: CDN integration with OSS and API Gateway CDN support (#195)
This pull request introduces support for Alibaba Cloud CDN and OSS Transfer Acceleration, expands the SDK client layer, and includes dependency upgrade fixes and code review corrections. ## Major Features ### CDN and Transfer Acceleration Support - CDN acceleration and OSS Transfer Acceleration for static website hosting - Simple (`cdn: true`) and advanced configuration options - Dual-layer acceleration (CDN + Transfer Acceleration) - Full CDN lifecycle: domain creation, certificate binding, cache/compression/protocol/HTTPS redirect configuration ### SDK Client Expansion - New `cdnOperations` module with domain, certificate, cache, protocol, compression, and HTTPS redirect management - CDN SDK client integrated into Aliyun client factory - DNS operations for CNAME record management ## Bug Fixes & Corrections ### CDN API Fix (Critical) - `applyProtocolConfig` now uses correct `forward_scheme` feature (not `range`) for origin protocol configuration - The `range` feature controls back-to-origin range slicing, not protocol. Origin protocol requires `forward_scheme` with `enable` parameter. ### Dependency Upgrade Compatibility - CDN SDK v9.2.0: `SetDomainServerCertificate` → `SetCdnDomainSSLCertificate` API migration - @types/jest v30: tsconfig `types` field for Jest globals - Flaky test retry logic for ECONNRESET race condition ### Code Quality - Added `dns` property to `MockAliyunClient` type (was missing from mock) - Removed redundant `isCdnEnabled` double-check in OSS www CDN block - Added 12 tests for `BatchSetCdnDomainConfig` functions (`applyCacheConfig`, `applyProtocolConfig`, `applyCompression`, `applyHttpsRedirect`) ## Documentation - Updated README with CDN/acceleration configuration examples - Clarified project value proposition in English and Chinese docs ## Test Coverage - 128 test suites, 2219 tests passed - 94.31% coverage (above 85% threshold) ## Commits 1. `feat: CDN integration with OSS and API Gateway CDN support` - Original feature 2. `fix: resolve dependency upgrade compatibility issues` - SDK/API migration 3. `fix: correct CDN origin protocol API and code review issues` - Bug fixes and tests
1 parent 2163ebb commit 3900330

42 files changed

Lines changed: 6809 additions & 1021 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ coverage/
66
.DS_Store
77
artifacts/
88
.serverlessinsight/
9+
.omo/

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
1010
[![codecov](https://codecov.io/gh/geek-fun/serverlessinsight/graph/badge.svg?token=ISW7MFuSlf)](https://codecov.io/gh/geek-fun/serverlessinsight)
1111

12-
**Full life cycle cross-provider serverless application management for your fast-growing business**
12+
**Describe your app. We handle the rest.**
13+
14+
*Full life cycle cross-provider serverless application management for your fast-growing business*
1315

1416
[Website](https://serverlessinsight.geekfun.club)[Documentation](https://serverlessinsight.geekfun.club)[Examples](./samples)[中文文档](./README.zh-CN.md)
1517

@@ -344,6 +346,61 @@ For OSS static website hosting, ServerlessInsight supports:
344346
345347
For detailed configuration, see [OSS Custom Domain Binding Guide](./docs/oss-custom-domain-binding.md).
346348

349+
### CDN Acceleration & OSS Transfer Acceleration
350+
351+
ServerlessInsight supports CDN acceleration and OSS Transfer Acceleration for buckets, enabling global content delivery and optimized origin fetch.
352+
353+
**CDN** (`cdn`): Create a CDN distribution in front of your bucket for edge caching and global acceleration. Accepts `boolean` (simple on/off) or `object` for advanced configuration:
354+
355+
```yaml
356+
buckets:
357+
# Simple: CDN with sensible defaults
358+
my_site:
359+
name: my-static-site
360+
website:
361+
code: ./dist
362+
index: index.html
363+
domain:
364+
domain_name: www.example.com
365+
certificate_id: cas-abc123
366+
cdn: true
367+
368+
# Advanced: CDN with custom config
369+
releases:
370+
name: app-releases
371+
security:
372+
acl: PRIVATE
373+
domain:
374+
domain_name: releases.example.com
375+
cdn:
376+
enabled: true
377+
cdn_type: download # web | download | video
378+
scope: global # domestic | overseas | global
379+
```
380+
381+
**Transfer Acceleration** (`accelerate`): Enables OSS Transfer Acceleration for cross-region/global data transfers. Routes traffic through Alibaba backbone network:
382+
383+
```yaml
384+
buckets:
385+
cross_region_backups:
386+
name: backup-bucket
387+
domain:
388+
domain_name: backups.internal.example.com
389+
accelerate: true # No CDN, just accelerate
390+
391+
# CDN + Accelerate (dual-layer)
392+
global_assets:
393+
name: global-assets
394+
domain:
395+
domain_name: assets.example.com
396+
cdn:
397+
enabled: true
398+
cdn_type: web
399+
accelerate: true # CDN origin uses accelerated endpoint
400+
```
401+
402+
**Backward Compatibility**: Existing `website.domain` config continues to work. When a bucket uses `website.domain` without the top-level `domain` block, a deprecation notice is logged suggesting migration to the canonical form.
403+
347404
---
348405

349406
## 🗄️ State Management

README.zh-CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
1010
[![codecov](https://codecov.io/gh/geek-fun/serverlessinsight/graph/badge.svg?token=ISW7MFuSlf)](https://codecov.io/gh/geek-fun/serverlessinsight)
1111

12-
**为快速增长的业务提供全生命周期跨云服务商的 Serverless 应用管理**
12+
**描述你的应用,剩下的交给我们。**
13+
14+
*为快速增长的业务提供全生命周期跨云服务商的 Serverless 应用管理*
1315

1416
[官方网站](https://serverlessinsight.geekfun.club)[文档](https://serverlessinsight.geekfun.club)[示例](./samples)[English](./README.md)
1517

docs/adr/003-cdn-integration.md

Lines changed: 611 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)