@kirkelliott/zap 0.1.18 → 0.1.19

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.
Files changed (2) hide show
  1. package/README.md +30 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -179,6 +179,36 @@ export default async (req) => {
179
179
  GET https://your-endpoint/proxy?url=https://api.example.com/data
180
180
  ```
181
181
 
182
+ ### Shared layout — imports in action
183
+
184
+ ```js
185
+ // lib/page.zap — shared layout
186
+ export default (title, content) => ({
187
+ headers: { 'content-type': 'text/html' },
188
+ body: `<!doctype html><html>...${title}...${content}...</html>`,
189
+ })
190
+ ```
191
+
192
+ ```js
193
+ // iss.zap — ISS position, live
194
+ export default async (req) => {
195
+ const page = await zap('lib/page')
196
+ const { iss_position } = await (await fetch('http://api.open-notify.org/iss-now.json')).json()
197
+ return page('ISS', `${iss_position.latitude} / ${iss_position.longitude}`)
198
+ }
199
+ ```
200
+
201
+ ```js
202
+ // astros.zap — who's in space right now
203
+ export default async (req) => {
204
+ const page = await zap('lib/page')
205
+ const { people } = await (await fetch('http://api.open-notify.org/astros.json')).json()
206
+ return page('In space', people.map(p => p.name).join(', '))
207
+ }
208
+ ```
209
+
210
+ Both pages share `lib/page.zap`. Update that one file in S3 — both pages change instantly. S3 is the module system.
211
+
182
212
  ---
183
213
 
184
214
  ## CLI
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirkelliott/zap",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Drop a .zap file in S3. It becomes an API endpoint.",
5
5
  "main": "dist/handler.js",
6
6
  "bin": {