@kirkelliott/zap 0.1.21 → 0.1.22
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 +23 -24
- package/package.json +1 -1
- package/demo/live.zap +0 -4
package/README.md
CHANGED
|
@@ -213,20 +213,38 @@ Both pages share `lib/page.zap`. Update that one file in S3 — both pages chang
|
|
|
213
213
|
|
|
214
214
|
## Environments
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
Each environment is a fully isolated AWS stack — its own S3 bucket, Lambda function, KV table, and URL. `prod` is the default. No flags needed for prod.
|
|
217
217
|
|
|
218
218
|
```bash
|
|
219
|
+
# spin up staging (takes ~30 seconds, same as init)
|
|
219
220
|
zap init --env staging
|
|
221
|
+
|
|
222
|
+
# deploy and test there
|
|
220
223
|
zap deploy --env staging api.zap
|
|
224
|
+
curl https://staging-url.lambda-url.us-east-1.on.aws/api
|
|
225
|
+
|
|
226
|
+
# promote to prod when ready
|
|
227
|
+
zap promote api --from staging --to prod
|
|
221
228
|
```
|
|
222
229
|
|
|
223
|
-
|
|
230
|
+
`promote` copies the file from one bucket to the other. The prod URL is live instantly.
|
|
224
231
|
|
|
225
|
-
|
|
226
|
-
|
|
232
|
+
`.zaprc` stores each environment under its own key:
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"prod": { "bucket": "zap-a3f2b8c1", "url": "https://abc.lambda-url…", … },
|
|
237
|
+
"staging": { "bucket": "zap-f9e2d4c7", "url": "https://xyz.lambda-url…", … }
|
|
238
|
+
}
|
|
227
239
|
```
|
|
228
240
|
|
|
229
|
-
|
|
241
|
+
Every command accepts `--env`:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
zap ls --env staging
|
|
245
|
+
zap rollback api --env staging
|
|
246
|
+
zap rm old-handler --env staging
|
|
247
|
+
```
|
|
230
248
|
|
|
231
249
|
---
|
|
232
250
|
|
|
@@ -308,23 +326,4 @@ MIT
|
|
|
308
326
|
|
|
309
327
|
---
|
|
310
328
|
|
|
311
|
-
The file in S3 is just a carrier. You don't need it.
|
|
312
|
-
|
|
313
|
-
```js
|
|
314
|
-
// live.zap
|
|
315
|
-
export default async (req) => {
|
|
316
|
-
if (!req.body) return { status: 400, body: 'POST a function' }
|
|
317
|
-
return { body: await eval(`(${req.body})`)({ kv, fetch }) }
|
|
318
|
-
}
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
```bash
|
|
322
|
-
curl -X POST https://your-endpoint/live \
|
|
323
|
-
-d 'async ({ kv }) => kv.get("visits")'
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
Deploy `live.zap` once. Then POST JavaScript directly — no S3, no CLI, no deploy step. The runtime running inside itself.
|
|
327
|
-
|
|
328
|
-
---
|
|
329
|
-
|
|
330
329
|
**[live demo →](https://zn2qgaqlofvauxmoncf36m4ynq0pfarj.lambda-url.us-east-1.on.aws/)**
|
package/package.json
CHANGED
package/demo/live.zap
DELETED