cloudfrontize 1.1.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -79
- package/dist/cli.js +24 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
# cloudfrontize
|
|
2
|
+
|
|
2
3
|
[](https://github.com/sponsors/felipecarrillo100)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
📜 **Changelog:** See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
#### A high-performance, high-fidelity local emulator for AWS Lambda@Edge and CloudFront Functions.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
## 📦 Getting started
|
|
16
|
+
Get up and running in seconds. No complex AWS IAM roles, no stack traces—just your code, running locally.
|
|
3
17
|
|
|
4
|
-
|
|
5
|
-
|
|
18
|
+
### Install it **Globally:**
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g cloudfrontize
|
|
22
|
+
```
|
|
23
|
+
Once installed, you can rule the Edge from any directory by simply typing `cloudfrontize ./www` (specifying your static folder).
|
|
24
|
+
|
|
25
|
+
Point it at your static files folder (`./www`, `./dist` or `./public`) and point to your Lambda@Edge `.js` file. CloudFrontize handles the rest.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cloudfrontize ./folder --edge ./lambda-at-age-logic.js
|
|
29
|
+
```
|
|
30
|
+
OR
|
|
31
|
+
```bash
|
|
32
|
+
npx cloudfrontize ./folder --edge ./lambda-at-age-logic.js
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 📣 Stop bowing to the deployment bar!
|
|
6
38
|
|
|
7
39
|
**Rule the Edge** and become the Hero of the Cloud. **Escape the "Deploy-and-Pray" cycle.** We’ve all been there: you tweak one security header, hit "Deploy," and... **you wait.** For 15 agonizing minutes, you watch a spinning "In Progress" status as AWS propagates your code globally. If there’s a tiny typo? You won't know until you hit a **502 Bad Gateway** and go hunting through CloudWatch logs buried in a random region.
|
|
8
40
|
|
|
@@ -26,7 +58,7 @@ The CloudFront/Lambda@Edge development loop is notoriously painful. Propagation
|
|
|
26
58
|
|
|
27
59
|
**CloudFrontize** eliminates the wait and the risk:
|
|
28
60
|
|
|
29
|
-
* **Zero-Config Integration:** If you know how to use Vercel's [serve](https://www.
|
|
61
|
+
* **Zero-Config Integration:** If you know how to use Vercel's [serve](https://www.npmjs.com/package/serve)) package, you already know how to use `cloudfrontize`.
|
|
30
62
|
* **Real-Time Hot Reloading:** Tweak your URI rewrites or security headers and see the results instantly on browser refresh. No packaging, no uploading, no waiting for the "In Progress" spinner.
|
|
31
63
|
* **Debug directly to the console:** Stop hunting for logs in hidden CloudWatch streams across random regions. See your console.log outputs and execution errors live **in your terminal**.
|
|
32
64
|
* **Production Fidelity:** Emulates in detail CloudFront-specific features & quirks, like the **10MB auto-compression limit**, header blacklisting, and URI normalization.
|
|
@@ -50,48 +82,11 @@ While tools like `serverless-offline` or `SAM CLI` are great for standard Lambda
|
|
|
50
82
|
|
|
51
83
|
**CloudFrontize** is not just a runner; it's a **Linter at the Edge**, ensuring your code is valid *before* the 15-minute propagation wait.
|
|
52
84
|
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## 📦 Install & Go
|
|
57
|
-
Get up and running in seconds. No complex AWS IAM roles, no stack traces—just your code, running locally.
|
|
58
|
-
|
|
59
|
-
### Install it **Globally:**
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
npm install -g cloudfrontize
|
|
63
|
-
```
|
|
64
|
-
Once installed, you can rule the Edge from any directory by simply typing `cloudfrontize ./www` (specifying your static folder).
|
|
65
|
-
|
|
66
|
-
Point it at your static files folder (`./www`, `./dist` or `./public`) and point to your Lambda@Edge `.js` file. CloudFrontize handles the rest.
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
cloudfrontize ./folder --edge ./lambda-at-age-logic.js
|
|
70
|
-
```
|
|
71
|
-
OR
|
|
72
|
-
```bash
|
|
73
|
-
npx cloudfrontize ./folder --edge ./lambda-at-age-logic.js
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
## 🎓 CloudFrontize Academy (Tutorial)
|
|
79
|
-
|
|
80
|
-
New to Lambda@Edge? We've built a comprehensive, hands-on tutorial to take you from **Newbie to Production Pro**.
|
|
81
|
-
|
|
82
|
-
Our **[CloudFrontize Academy](./tutorial/README.md)** includes 10 thematic exercises covering:
|
|
83
|
-
* **Module 1: Foundations** (Security Headers, Redirects, Normalization)
|
|
84
|
-
* **Module 2: Origin Intelligence** (A/B Testing, Geo-Localization, Header Cleaning)
|
|
85
|
-
* **Module 3: Edge Computing** (Custom Auth, Maintenance Pages, Payload Inspection)
|
|
86
|
-
* **Module 4: Production Workflows** (Variable Baking & Deployment)
|
|
87
|
-
|
|
88
|
-
Each exercise comes with a **Business Scenario**, **Starter Template**, and **Full Solution**.
|
|
89
|
-
|
|
90
85
|
---
|
|
91
86
|
|
|
92
87
|
## 🛠️ CLI Options & Configuration
|
|
93
88
|
|
|
94
|
-
`cloudfrontize` is designed to be a drop-in replacement for the popular [serve](https://www.
|
|
89
|
+
`cloudfrontize` is designed to be a drop-in replacement for the popular [serve](https://www.npmjs.com/package/serve), we all know and love, but with "Edge Superpowers!"
|
|
95
90
|
|
|
96
91
|
| Flag | Description | Default |
|
|
97
92
|
| --- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
|
|
@@ -116,6 +111,7 @@ Each exercise comes with a **Business Scenario**, **Starter Template**, and **Fu
|
|
|
116
111
|
|
|
117
112
|
---
|
|
118
113
|
|
|
114
|
+
|
|
119
115
|
## 🚀 Lambda@Edge Integration
|
|
120
116
|
|
|
121
117
|
Since there is no AWS CloudFront Console to configure your triggers locally, **it is mandatory to include `exports.hookType` in your JavaScript file.** If this line is missing, CloudFrontize will not know when to fire your function and will ignore the file.
|
|
@@ -139,27 +135,15 @@ When pointing `--cff` to a directory, files must follow a strict naming conventi
|
|
|
139
135
|
|
|
140
136
|
Files within a directory are executed in **lexicographical order**.
|
|
141
137
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
```javascript
|
|
145
|
-
function handler(event) {
|
|
146
|
-
var request = event.request;
|
|
147
|
-
var uri = request.uri;
|
|
138
|
+
## 🛡️ Engineered for Fidelity
|
|
148
139
|
|
|
149
|
-
|
|
150
|
-
if (uri === '/old-path') {
|
|
151
|
-
return {
|
|
152
|
-
statusCode: 301,
|
|
153
|
-
statusDescription: 'Moved Permanently',
|
|
154
|
-
headers: {
|
|
155
|
-
'location': { value: '/new-path' }
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
}
|
|
140
|
+
Don't just simulate the Edge—**master it.** CloudFrontize is built to mirror the high-stakes environment of a live AWS PoP (Point of Presence).
|
|
159
141
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
142
|
+
* **⚡ Native Async/Await Support:** Whether your middleware is a simple redirect or a complex, asynchronous database lookup, CloudFrontize handles `async` handlers and Promises with the same grace as the live Lambda@Edge runtime.
|
|
143
|
+
* **🧩 Multi-Hook Testing:** Pass a directory to `--edge` and CloudFrontize will automatically mount every valid Lambda it finds. Orchestrate your **Viewer Request**, **Origin Request**, and **Response** hooks in one unified local environment.
|
|
144
|
+
* **📦 RequestBody Access:** Use `event.Records[0].cf.request.body` to access base64 encoded payloads. We support the standard AWS buffering logic.
|
|
145
|
+
* **🚫 Strict Header & Body Validation:** Use `--strict` to identify "Read-only" or "Forbidden" headers for **both request and response hooks**, as well as the **40KB viewer-request body limit** and the **1MB generated response limit** in real-time. We trigger **502 Bad Gateway** errors locally for the same illegal mutations that fail in production.
|
|
146
|
+
* **🎭 Mocked Context & Events:** We provide a high-fidelity `event` and `context` object, ensuring your logging, metrics, and custom error-handling tools work exactly as they would in production.
|
|
163
147
|
|
|
164
148
|
---
|
|
165
149
|
|
|
@@ -168,19 +152,11 @@ function handler(event) {
|
|
|
168
152
|
|
|
169
153
|
We’ve bundled a complete, interactive sample to show you the power of **CloudFrontize**. It protects a premium dog photography gallery using a `viewer-request` authentication gate.
|
|
170
154
|
|
|
171
|
-
###
|
|
155
|
+
### Lambda@Edge sample
|
|
172
156
|
Clone the GitHub repo
|
|
173
157
|
```shell
|
|
174
158
|
git clone https://github.com/felipecarrillo100/cloudfrontize.git
|
|
175
159
|
```
|
|
176
|
-
Then run
|
|
177
|
-
```bash
|
|
178
|
-
cloudfrontize ./www -e ./samples/medium/lambda-edge-authorization.js -d -C
|
|
179
|
-
```
|
|
180
|
-
* The `www` folder contains the sample files (html, js, css, etc.)
|
|
181
|
-
* The `lambda-edge-authorization.js` contains the lambda@edge logic
|
|
182
|
-
* The `-d` option enables debug messages while `-C` enables CORS
|
|
183
|
-
* Default port is 3000, you can now open your browser at http://localhost:3000/
|
|
184
160
|
|
|
185
161
|
### The Sample Logic (`lambda-edge-authorization.js`)
|
|
186
162
|
|
|
@@ -200,7 +176,7 @@ exports.handler = (event, context, callback) => {
|
|
|
200
176
|
|
|
201
177
|
// Credentials for demo purposes
|
|
202
178
|
const user = "admin";
|
|
203
|
-
const password = "
|
|
179
|
+
const password = "password";
|
|
204
180
|
|
|
205
181
|
const authString = "Basic " + Buffer.from(user + ":" + password).toString("base64");
|
|
206
182
|
|
|
@@ -227,27 +203,66 @@ exports.handler = (event, context, callback) => {
|
|
|
227
203
|
callback(null, request);
|
|
228
204
|
};
|
|
229
205
|
```
|
|
206
|
+
Then run
|
|
207
|
+
```bash
|
|
208
|
+
cloudfrontize ./www -e ./samples/medium/lambda-edge-authorization.js -d -C
|
|
209
|
+
```
|
|
210
|
+
* The `www` folder contains the sample files (html, js, css, etc.)
|
|
211
|
+
* The `lambda-edge-authorization.js` contains the lambda@edge logic
|
|
212
|
+
* The `-d` option enables debug messages while `-C` enables CORS
|
|
213
|
+
* Default port is 3000, you can now open your browser at http://localhost:3000/
|
|
214
|
+
* The user: admin and the password: password as you see in the Lambda@Edge logic.
|
|
230
215
|
|
|
216
|
+
### A CFF Example
|
|
217
|
+
Your file must start with `viewer-request` or `viewer-response` to let the simulator know the type of CFF we want to execute. In this case we have called it:`viewer-request-redirect.js`
|
|
218
|
+
```javascript
|
|
219
|
+
function handler(event) {
|
|
220
|
+
var request = event.request;
|
|
221
|
+
var uri = request.uri;
|
|
222
|
+
|
|
223
|
+
// Direct response (short-circuits the pipeline)
|
|
224
|
+
if (uri === '/promo') {
|
|
225
|
+
return {
|
|
226
|
+
statusCode: 301,
|
|
227
|
+
statusDescription: 'Moved Permanently',
|
|
228
|
+
headers: {
|
|
229
|
+
'location': { value: '/summer-sale' }
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return request;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Run with:
|
|
239
|
+
```bash
|
|
240
|
+
cloudfrontize ./www --cff ./samples/cff/viewer-request-redirect.js -d --mode website
|
|
241
|
+
```
|
|
242
|
+
* `-d` Enabled debug, and `--mode website` takes care of appending `index.html` to folders
|
|
243
|
+
* Open in browser http://localhost:3000/promo
|
|
244
|
+
* You will be redirected tot http://localhost:3000/summer-sale
|
|
231
245
|
---
|
|
232
246
|
|
|
233
|
-
|
|
247
|
+
## 🎓 CloudFrontize Academy (Tutorial)
|
|
234
248
|
|
|
235
|
-
|
|
249
|
+
New to Lambda@Edge? We've built a comprehensive, hands-on tutorial to take you from **Newbie to Production Pro**.
|
|
236
250
|
|
|
237
|
-
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
251
|
+
Our **[CloudFrontize Academy](./tutorial/README.md)** includes 10 thematic exercises covering:
|
|
252
|
+
* **Module 1: Foundations** (Security Headers, Redirects, Normalization)
|
|
253
|
+
* **Module 2: Origin Intelligence** (A/B Testing, Geo-Localization, Header Cleaning)
|
|
254
|
+
* **Module 3: Edge Computing** (Custom Auth, Maintenance Pages, Payload Inspection)
|
|
255
|
+
* **Module 4: Production Workflows** (Variable Baking & Deployment)
|
|
256
|
+
* **Module 5: Cloud Front Functions** (CFF)
|
|
242
257
|
|
|
243
|
-
|
|
258
|
+
Each exercise comes with a **Business Scenario**, **Starter Template**, and **Full Solution**.
|
|
244
259
|
|
|
260
|
+
---
|
|
245
261
|
|
|
246
262
|
### License
|
|
247
263
|
|
|
248
264
|
**CloudFrontize** is licensed under the **[PolyForm Noncommercial 1.0.0](https://www.google.com/search?q=https://polyformproject.org/licenses/noncommercial/1.0.0/)**. For the full legal text and specific terms, please refer to the [LICENSE](https://www.google.com/search?q=./LICENSE) file in this package.
|
|
249
265
|
|
|
250
|
-
|
|
251
266
|
* **✅ Free for Individuals & Education:** 100% free for personal projects, open-source contributions, students, and researchers. This includes full access to the **CloudFrontize Academy**.
|
|
252
267
|
* **💼 Requires a Commercial License:** Use by for-profit organizations, or for work performed on behalf of a for-profit entity, requires a paid Commercial License.
|
|
253
268
|
* **⏳ 30-Day Business Trial:** We offer a one-month free evaluation period for professional teams. Integrate CloudFrontize into your workflow, experience the "Zero-Wait" deployment cycle, and measure your team's productivity gains before committing.
|