@jimhoyd/urlcode 0.3.0 → 0.4.0-alpha.2

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 (380) hide show
  1. package/.claude/skills/urlcode-authoring/SKILL.md +122 -0
  2. package/.claude/skills/urlcode-operations/SKILL.md +108 -0
  3. package/.claude-plugin/marketplace.json +18 -0
  4. package/CONTRIBUTING.md +30 -2
  5. package/README.md +195 -255
  6. package/ROADMAP.md +143 -15
  7. package/SECURITY.md +31 -9
  8. package/dist/BUILD-MANIFEST.json +72 -47
  9. package/dist/adapters.js +4 -23
  10. package/dist/agent-lists.js +1 -1
  11. package/dist/agents-guide.js +113 -0
  12. package/dist/authoring-files.js +60 -0
  13. package/dist/authoring.js +11 -1
  14. package/dist/aws.js +4 -3
  15. package/dist/build-cloudflare.js +11 -24
  16. package/dist/build-static.js +134 -0
  17. package/dist/bulk.js +37 -0
  18. package/dist/capabilities.js +262 -0
  19. package/dist/capability-query.js +71 -0
  20. package/dist/catalog.js +105 -0
  21. package/dist/cli.js +165 -34
  22. package/dist/client-address.js +1 -1
  23. package/dist/compliance-rules/baseline.js +9 -17
  24. package/dist/compliance-rules/privacy.js +7 -18
  25. package/dist/compliance-rules/shared.js +0 -2
  26. package/dist/compliance-rules/strict.js +5 -5
  27. package/dist/compliance.js +6 -8
  28. package/dist/conditions.js +88 -0
  29. package/dist/config.js +69 -6
  30. package/dist/context.js +155 -0
  31. package/dist/ecosystem-cli.js +88 -0
  32. package/dist/egress.js +98 -0
  33. package/dist/examples.js +92 -0
  34. package/dist/explain-cli.js +64 -0
  35. package/dist/explain.js +131 -0
  36. package/dist/extensions.js +231 -0
  37. package/dist/function-sources.js +49 -5
  38. package/dist/function-worker.js +3 -1
  39. package/dist/functions.js +84 -13
  40. package/dist/guest-api.js +29 -3
  41. package/dist/index.js +40 -6
  42. package/dist/init-with.js +165 -0
  43. package/dist/interchange-cli.js +42 -0
  44. package/dist/interchange.js +189 -0
  45. package/dist/manifest.js +109 -0
  46. package/dist/match.js +2 -2
  47. package/dist/mcp-authoring.js +147 -0
  48. package/dist/mcp.js +97 -0
  49. package/dist/observability.js +7 -21
  50. package/dist/operator-host.js +29 -0
  51. package/dist/plugins.js +12 -0
  52. package/dist/policies/agents.js +2 -2
  53. package/dist/policies/cache.js +8 -3
  54. package/dist/policies/compression.js +2 -1
  55. package/dist/policies/security.js +0 -0
  56. package/dist/policies.js +1 -1
  57. package/dist/policy.js +56 -15
  58. package/dist/prerender.js +100 -41
  59. package/dist/project-tests.js +3 -3
  60. package/dist/provider-verification.js +92 -0
  61. package/dist/proxy.js +44 -0
  62. package/dist/readiness.js +34 -11
  63. package/dist/recipes.js +41 -0
  64. package/dist/route-diff.js +106 -0
  65. package/dist/router.js +45 -7
  66. package/dist/runtime.js +164 -64
  67. package/dist/sandbox.js +48 -0
  68. package/dist/scaffold.js +0 -0
  69. package/dist/schema-query.js +62 -0
  70. package/dist/scripts/operational-drills.js +12 -54
  71. package/dist/server.js +3 -29
  72. package/dist/signals.js +24 -0
  73. package/dist/site.js +0 -0
  74. package/dist/tooling.js +96 -0
  75. package/dist/trusted-functions.js +210 -0
  76. package/dist/types/adapters.d.ts +7 -4
  77. package/dist/types/agent-lists.d.ts +0 -1
  78. package/dist/types/agents-guide.d.ts +17 -0
  79. package/dist/types/authoring-files.d.ts +10 -0
  80. package/dist/types/aws.d.ts +3 -1
  81. package/dist/types/build-cloudflare.d.ts +1 -0
  82. package/dist/types/build-static.d.ts +43 -0
  83. package/dist/types/bulk.d.ts +27 -0
  84. package/dist/types/capabilities.d.ts +64 -0
  85. package/dist/types/capability-query.d.ts +24 -0
  86. package/dist/types/catalog.d.ts +65 -0
  87. package/dist/types/client-address.d.ts +0 -1
  88. package/dist/types/compliance-rules/baseline.d.ts +1 -9
  89. package/dist/types/compliance-rules/privacy.d.ts +1 -4
  90. package/dist/types/compliance-rules/shared.d.ts +0 -2
  91. package/dist/types/compliance-rules/strict.d.ts +0 -5
  92. package/dist/types/compliance.d.ts +0 -3
  93. package/dist/types/conditions.d.ts +19 -0
  94. package/dist/types/config.d.ts +21 -2
  95. package/dist/types/context.d.ts +66 -0
  96. package/dist/types/ecosystem-cli.d.ts +17 -0
  97. package/dist/types/egress.d.ts +46 -0
  98. package/dist/types/examples.d.ts +50 -0
  99. package/dist/types/explain-cli.d.ts +11 -0
  100. package/dist/types/explain.d.ts +95 -0
  101. package/dist/types/extensions.d.ts +177 -0
  102. package/dist/types/function-sources.d.ts +9 -0
  103. package/dist/types/functions.d.ts +48 -5
  104. package/dist/types/guest-api.d.ts +1 -0
  105. package/dist/types/index.d.ts +36 -6
  106. package/dist/types/init-with.d.ts +30 -0
  107. package/dist/types/interchange-cli.d.ts +16 -0
  108. package/dist/types/interchange.d.ts +42 -0
  109. package/dist/types/manifest.d.ts +79 -0
  110. package/dist/types/match.d.ts +1 -0
  111. package/dist/types/mcp-authoring.d.ts +92 -0
  112. package/dist/types/mcp.d.ts +12 -0
  113. package/dist/types/observability.d.ts +3 -14
  114. package/dist/types/operator-host.d.ts +8 -0
  115. package/dist/types/plugins.d.ts +2 -0
  116. package/dist/types/policies/agents.d.ts +0 -2
  117. package/dist/types/policies/compression.d.ts +2 -0
  118. package/dist/types/policies/security.d.ts +0 -1
  119. package/dist/types/policy.d.ts +15 -4
  120. package/dist/types/project-tests.d.ts +3 -2
  121. package/dist/types/provider-verification.d.ts +53 -0
  122. package/dist/types/proxy.d.ts +21 -0
  123. package/dist/types/readiness.d.ts +10 -3
  124. package/dist/types/recipes.d.ts +30 -0
  125. package/dist/types/route-diff.d.ts +27 -0
  126. package/dist/types/router.d.ts +2 -1
  127. package/dist/types/runtime.d.ts +11 -27
  128. package/dist/types/sandbox.d.ts +12 -0
  129. package/dist/types/scaffold.d.ts +0 -2
  130. package/dist/types/schema-query.d.ts +12 -0
  131. package/dist/types/server.d.ts +1 -4
  132. package/dist/types/signals.d.ts +25 -0
  133. package/dist/types/site.d.ts +0 -1
  134. package/dist/types/tooling.d.ts +115 -0
  135. package/dist/types/trusted-functions.d.ts +29 -0
  136. package/dist/types/types.d.ts +71 -7
  137. package/dist/types/typescript-authoring.d.ts +12 -0
  138. package/dist/types/vercel.d.ts +3 -1
  139. package/dist/types/verify-deployment.d.ts +47 -0
  140. package/dist/types.js +37 -5
  141. package/dist/typescript-authoring.js +142 -0
  142. package/dist/vercel.js +4 -3
  143. package/dist/verify-deployment.js +270 -0
  144. package/docs/AI-AUTHORING.md +232 -15
  145. package/docs/AWS.md +4 -4
  146. package/docs/BEST-PRACTICES.md +3 -2
  147. package/docs/BULK.md +79 -0
  148. package/docs/CAPABILITIES.md +192 -0
  149. package/docs/CAPACITY.md +129 -32
  150. package/docs/CI.md +142 -0
  151. package/docs/CLOUDFLARE.md +1 -2
  152. package/docs/COMPLIANCE.md +6 -9
  153. package/docs/CONDITIONS.md +74 -0
  154. package/docs/DEPLOYMENT-CHECKS.md +108 -0
  155. package/docs/EGRESS.md +125 -0
  156. package/docs/EXTENSIONS.md +398 -0
  157. package/docs/FRAMEWORK.md +198 -0
  158. package/docs/FUNCTION-SECURITY.md +129 -32
  159. package/docs/INSTALL.md +45 -12
  160. package/docs/INTERCHANGE.md +134 -0
  161. package/docs/LOAD-TESTING.md +4 -4
  162. package/docs/MIDDLEWARE-EXAMPLES.md +75 -0
  163. package/docs/MIDDLEWARE.md +29 -16
  164. package/docs/MONITORING.md +2 -19
  165. package/docs/NEXT-PHASE-PLAN.md +98 -0
  166. package/docs/NEXT-STEPS.md +634 -0
  167. package/docs/OBSERVABILITY.md +11 -18
  168. package/docs/OPEN-DECISIONS.md +212 -0
  169. package/docs/OPERATIONAL-PROOF.md +30 -31
  170. package/docs/OPERATIONS.md +29 -35
  171. package/docs/PLUGINS.md +37 -0
  172. package/docs/POLICIES.md +23 -309
  173. package/docs/PRERENDER.md +41 -1
  174. package/docs/PROJECT-DIRECTION.md +75 -8
  175. package/docs/PROVIDER-VERIFICATION.md +84 -0
  176. package/docs/READINESS.md +21 -1
  177. package/docs/README.md +87 -34
  178. package/docs/RECIPES.md +99 -0
  179. package/docs/RELEASE-READINESS.md +57 -35
  180. package/docs/RELEASE-SECURITY.md +116 -7
  181. package/docs/RESILIENCE.md +16 -15
  182. package/docs/ROUTING.md +8 -10
  183. package/docs/SANDBOX-REVIEW.md +19 -6
  184. package/docs/SCAFFOLDING.md +0 -2
  185. package/docs/SECURITY-AUDIT.md +41 -1
  186. package/docs/SPECIFICATION.md +150 -29
  187. package/docs/SPIKE-AI-FRAMEWORK-BENCHMARK.md +287 -0
  188. package/docs/SPIKE-BUSINESS-SUITE.md +1021 -0
  189. package/docs/SPIKE-CORE-LAYERING.md +337 -0
  190. package/docs/SPIKE-DEFAULT-TRUST-MODEL.md +209 -0
  191. package/docs/SPIKE-EXTENSION-MODEL.md +419 -0
  192. package/docs/SPIKE-EXTENSIONS.md +6 -0
  193. package/docs/SPIKE-LAMBDA-COMPILE.md +201 -0
  194. package/docs/SPIKE-MONOREPO.md +322 -0
  195. package/docs/STANDARDS.md +150 -142
  196. package/docs/STARTERS.md +21 -1
  197. package/docs/STATIC.md +94 -0
  198. package/docs/TOOLING.md +295 -0
  199. package/docs/TUNNELS.md +0 -3
  200. package/docs/TYPESCRIPT-AUTHORING.md +82 -0
  201. package/docs/TYPESCRIPT.md +25 -4
  202. package/docs/USABILITY-REVIEW.md +129 -0
  203. package/docs/VERCEL.md +4 -5
  204. package/docs/VERSION-ALIGNMENT.md +205 -0
  205. package/docs/YAML-GUIDE.md +15 -479
  206. package/docs/YAML-REFERENCE.md +143 -22
  207. package/docs/policies/agents.md +1 -1
  208. package/docs/policies/cache.md +13 -0
  209. package/docs/policies/contract.md +52 -0
  210. package/docs/policies/hardened.md +56 -0
  211. package/docs/policies/interoperability.md +169 -0
  212. package/docs/policies/operations.md +45 -0
  213. package/docs/yaml/assets.md +36 -0
  214. package/docs/yaml/conditions.md +20 -0
  215. package/docs/yaml/functions.md +160 -0
  216. package/docs/yaml/middleware.md +29 -0
  217. package/docs/yaml/organization.md +74 -0
  218. package/docs/yaml/policies.md +37 -0
  219. package/docs/yaml/redirects.md +64 -0
  220. package/docs/yaml/responses.md +57 -0
  221. package/docs/yaml/site.md +24 -0
  222. package/examples/assets/example.yaml +17 -0
  223. package/examples/aws/example.yaml +20 -0
  224. package/examples/cloudflare/example.yaml +19 -0
  225. package/examples/compliance/example.yaml +11 -0
  226. package/examples/conditions/README.md +12 -0
  227. package/examples/conditions/example.yaml +19 -0
  228. package/examples/conditions/tests/requests.json +13 -0
  229. package/examples/conditions/urlcode.yaml +24 -0
  230. package/examples/cookbook/README.md +8 -4
  231. package/examples/cookbook/example.yaml +17 -0
  232. package/examples/cookbook/functions/catalog.mjs +3 -0
  233. package/examples/cookbook/functions/fail.mjs +4 -0
  234. package/examples/cookbook/functions/items.mjs +3 -0
  235. package/examples/cookbook/functions/profile.mjs +3 -0
  236. package/examples/cookbook/functions/resource.mjs +3 -0
  237. package/examples/cookbook/functions/status.mjs +3 -0
  238. package/examples/cookbook/middleware/auth.mjs +48 -0
  239. package/examples/cookbook/middleware/body.mjs +15 -0
  240. package/examples/cookbook/middleware/bucket.mjs +29 -0
  241. package/examples/cookbook/middleware/cors.mjs +21 -0
  242. package/examples/cookbook/middleware/debug.mjs +13 -0
  243. package/examples/cookbook/middleware/envelope.mjs +11 -0
  244. package/examples/cookbook/middleware/errors.mjs +11 -0
  245. package/examples/cookbook/middleware/etag.mjs +18 -0
  246. package/examples/cookbook/middleware/locale.mjs +20 -0
  247. package/examples/cookbook/middleware/maintenance.mjs +10 -0
  248. package/examples/cookbook/middleware/methods.mjs +15 -0
  249. package/examples/cookbook/middleware/negotiate.mjs +20 -0
  250. package/examples/cookbook/middleware/referer.mjs +12 -0
  251. package/examples/cookbook/middleware/request-id.mjs +16 -0
  252. package/examples/cookbook/route-index.json +676 -0
  253. package/examples/cookbook/routes/middleware.yaml +126 -0
  254. package/examples/cookbook/tests/requests.json +526 -0
  255. package/examples/cookbook/urlcode.yaml +1 -0
  256. package/examples/egress/README.md +22 -0
  257. package/examples/egress/example.yaml +19 -0
  258. package/examples/egress/urlcode.yaml +19 -0
  259. package/examples/extensions/README.md +7 -0
  260. package/examples/extensions/example.yaml +21 -0
  261. package/examples/extensions/urlcode.yaml +25 -0
  262. package/examples/monitoring/example.yaml +8 -0
  263. package/examples/prerender/README.md +2 -2
  264. package/examples/prerender/example.yaml +16 -0
  265. package/examples/provider-conformance/README.md +12 -0
  266. package/examples/provider-conformance/example.yaml +14 -0
  267. package/examples/provider-conformance/urlcode.yaml +34 -0
  268. package/examples/tunnel/example.yaml +8 -0
  269. package/examples/vercel/example.yaml +19 -0
  270. package/llms-full.txt +3084 -0
  271. package/llms.txt +61 -21
  272. package/package.json +36 -7
  273. package/packaging/claude-plugin/.claude-plugin/plugin.json +19 -0
  274. package/packaging/claude-plugin/skills/urlcode-authoring/SKILL.md +122 -0
  275. package/packaging/claude-plugin/skills/urlcode-operations/SKILL.md +108 -0
  276. package/recipes/authenticated-json-api/README.md +51 -0
  277. package/recipes/authenticated-json-api/functions/profile.mjs +5 -0
  278. package/recipes/authenticated-json-api/recipe.yaml +34 -0
  279. package/recipes/authenticated-json-api/tests/requests.json +39 -0
  280. package/recipes/authenticated-json-api/urlcode.yaml +12 -0
  281. package/recipes/contact-form/README.md +25 -0
  282. package/recipes/contact-form/functions/contact.mjs +17 -0
  283. package/recipes/contact-form/recipe.yaml +33 -0
  284. package/recipes/contact-form/tests/requests.json +47 -0
  285. package/recipes/contact-form/urlcode.yaml +18 -0
  286. package/recipes/cors-api/README.md +16 -0
  287. package/recipes/cors-api/functions/items.mjs +3 -0
  288. package/recipes/cors-api/middleware/cors.mjs +21 -0
  289. package/recipes/cors-api/recipe.yaml +26 -0
  290. package/recipes/cors-api/tests/requests.json +65 -0
  291. package/recipes/cors-api/urlcode.yaml +12 -0
  292. package/recipes/health-page/README.md +13 -0
  293. package/recipes/health-page/recipe.yaml +23 -0
  294. package/recipes/health-page/tests/requests.json +36 -0
  295. package/recipes/health-page/urlcode.yaml +19 -0
  296. package/recipes/json-api/README.md +6 -0
  297. package/recipes/json-api/functions/echo.mjs +3 -0
  298. package/recipes/json-api/recipe.yaml +25 -0
  299. package/recipes/json-api/tests/requests.json +34 -0
  300. package/recipes/json-api/urlcode.yaml +12 -0
  301. package/recipes/middleware/README.md +34 -0
  302. package/recipes/middleware/functions/catalog.mjs +3 -0
  303. package/recipes/middleware/functions/fail.mjs +4 -0
  304. package/recipes/middleware/functions/items.mjs +3 -0
  305. package/recipes/middleware/functions/profile.mjs +3 -0
  306. package/recipes/middleware/functions/resource.mjs +3 -0
  307. package/recipes/middleware/functions/status.mjs +3 -0
  308. package/recipes/middleware/middleware/auth.mjs +48 -0
  309. package/recipes/middleware/middleware/body.mjs +15 -0
  310. package/recipes/middleware/middleware/bucket.mjs +29 -0
  311. package/recipes/middleware/middleware/cors.mjs +21 -0
  312. package/recipes/middleware/middleware/debug.mjs +13 -0
  313. package/recipes/middleware/middleware/envelope.mjs +11 -0
  314. package/recipes/middleware/middleware/errors.mjs +11 -0
  315. package/recipes/middleware/middleware/etag.mjs +18 -0
  316. package/recipes/middleware/middleware/locale.mjs +20 -0
  317. package/recipes/middleware/middleware/maintenance.mjs +10 -0
  318. package/recipes/middleware/middleware/methods.mjs +15 -0
  319. package/recipes/middleware/middleware/negotiate.mjs +20 -0
  320. package/recipes/middleware/middleware/referer.mjs +12 -0
  321. package/recipes/middleware/middleware/request-id.mjs +16 -0
  322. package/recipes/middleware/public/guide.txt +1 -0
  323. package/recipes/middleware/recipe.yaml +50 -0
  324. package/recipes/middleware/tests/requests.json +528 -0
  325. package/recipes/middleware/urlcode.yaml +127 -0
  326. package/recipes/protected-download/README.md +22 -0
  327. package/recipes/protected-download/files/report.txt +1 -0
  328. package/recipes/protected-download/recipe.yaml +31 -0
  329. package/recipes/protected-download/tests/requests.json +32 -0
  330. package/recipes/protected-download/urlcode.yaml +15 -0
  331. package/recipes/redirect/README.md +7 -0
  332. package/recipes/redirect/recipe.yaml +25 -0
  333. package/recipes/redirect/tests/requests.json +19 -0
  334. package/recipes/redirect/urlcode.yaml +9 -0
  335. package/recipes/static-plus-api/README.md +15 -0
  336. package/recipes/static-plus-api/functions/info.mjs +3 -0
  337. package/recipes/static-plus-api/public/assets/index.html +3 -0
  338. package/recipes/static-plus-api/public/assets/site.css +1 -0
  339. package/recipes/static-plus-api/public/index.html +8 -0
  340. package/recipes/static-plus-api/recipe.yaml +29 -0
  341. package/recipes/static-plus-api/tests/requests.json +56 -0
  342. package/recipes/static-plus-api/urlcode.yaml +23 -0
  343. package/recipes/typescript/README.md +8 -0
  344. package/recipes/typescript/functions/hello.ts +5 -0
  345. package/recipes/typescript/recipe.yaml +23 -0
  346. package/recipes/typescript/tests/requests.json +18 -0
  347. package/recipes/typescript/urlcode.yaml +5 -0
  348. package/recipes/webhook-receiver/README.md +20 -0
  349. package/recipes/webhook-receiver/functions/receive.mjs +16 -0
  350. package/recipes/webhook-receiver/recipe.yaml +27 -0
  351. package/recipes/webhook-receiver/tests/requests.json +59 -0
  352. package/recipes/webhook-receiver/urlcode.yaml +23 -0
  353. package/schemas/recipe.schema.json +139 -0
  354. package/schemas/urlcode.schema.json +659 -110
  355. package/skills/urlcode/SKILL.md +119 -0
  356. package/starters/default/.github/workflows/urlcode.yml +23 -0
  357. package/starters/default/.mcp.json +12 -0
  358. package/starters/default/AGENTS.md +79 -0
  359. package/starters/default/urlcode.yaml +0 -1
  360. package/dist/link-api.js +0 -136
  361. package/dist/link-cli.js +0 -141
  362. package/dist/link-events.js +0 -76
  363. package/dist/link-records.js +0 -31
  364. package/dist/link-store-worker.js +0 -150
  365. package/dist/link-store.js +0 -250
  366. package/dist/management-policy.js +0 -41
  367. package/dist/sqlite-version.js +0 -6
  368. package/dist/types/link-api.d.ts +0 -30
  369. package/dist/types/link-cli.d.ts +0 -36
  370. package/dist/types/link-events.d.ts +0 -27
  371. package/dist/types/link-records.d.ts +0 -11
  372. package/dist/types/link-store-worker.d.ts +0 -1
  373. package/dist/types/link-store.d.ts +0 -130
  374. package/dist/types/management-policy.d.ts +0 -9
  375. package/dist/types/sqlite-version.d.ts +0 -1
  376. package/docs/DYNAMIC-LINKS.md +0 -561
  377. package/docs/MANAGEMENT-SECURITY.md +0 -82
  378. package/examples/live-links/README.md +0 -11
  379. package/examples/live-links/tests/requests.json +0 -6
  380. package/examples/live-links/urlcode.yaml +0 -16
@@ -0,0 +1,528 @@
1
+ [
2
+ {
3
+ "path": "/api/private",
4
+ "status": 401,
5
+ "expectHeaders": {
6
+ "www-authenticate": "Bearer realm=\"cookbook\""
7
+ }
8
+ },
9
+ {
10
+ "path": "/api/private",
11
+ "status": 401,
12
+ "headers": {
13
+ "authorization": "Bearer wrong-token"
14
+ }
15
+ },
16
+ {
17
+ "path": "/api/private",
18
+ "status": 200,
19
+ "headers": {
20
+ "authorization": "Bearer cookbook-token"
21
+ },
22
+ "expectBody": "{\"private\":true}"
23
+ },
24
+ {
25
+ "path": "/api/private",
26
+ "status": 200,
27
+ "method": "HEAD",
28
+ "headers": {
29
+ "authorization": "Bearer cookbook-token"
30
+ },
31
+ "expectBody": ""
32
+ },
33
+ {
34
+ "path": "/admin/panel",
35
+ "status": 401,
36
+ "expectHeaders": {
37
+ "www-authenticate": "Basic realm=\"cookbook\", charset=\"UTF-8\""
38
+ }
39
+ },
40
+ {
41
+ "path": "/admin/panel",
42
+ "status": 401,
43
+ "headers": {
44
+ "authorization": "Basic YWRtaW46d3Jvbmc="
45
+ }
46
+ },
47
+ {
48
+ "path": "/admin/panel",
49
+ "status": 200,
50
+ "headers": {
51
+ "authorization": "Basic YWRtaW46Y29va2Jvb2stcGFzc3dvcmQ="
52
+ },
53
+ "expectBody": "Admin panel"
54
+ },
55
+ {
56
+ "path": "/admin/panel",
57
+ "status": 200,
58
+ "method": "HEAD",
59
+ "headers": {
60
+ "authorization": "Basic YWRtaW46Y29va2Jvb2stcGFzc3dvcmQ="
61
+ },
62
+ "expectBody": ""
63
+ },
64
+ {
65
+ "path": "/cors/data",
66
+ "status": 204,
67
+ "method": "OPTIONS",
68
+ "headers": {
69
+ "origin": "https://app.example.com",
70
+ "access-control-request-method": "GET"
71
+ },
72
+ "expectBody": "",
73
+ "expectHeaders": {
74
+ "access-control-allow-origin": "https://app.example.com",
75
+ "access-control-allow-methods": "GET, HEAD, OPTIONS",
76
+ "vary": "origin"
77
+ }
78
+ },
79
+ {
80
+ "path": "/cors/data",
81
+ "status": 204,
82
+ "method": "OPTIONS",
83
+ "headers": {
84
+ "origin": "https://evil.example.net"
85
+ },
86
+ "expectBody": "",
87
+ "expectHeaders": {
88
+ "vary": "origin"
89
+ }
90
+ },
91
+ {
92
+ "path": "/cors/data",
93
+ "status": 200,
94
+ "headers": {
95
+ "origin": "https://admin.example.com"
96
+ },
97
+ "expectBody": "{\"shared\":true}",
98
+ "expectHeaders": {
99
+ "access-control-allow-origin": "https://admin.example.com"
100
+ }
101
+ },
102
+ {
103
+ "path": "/cors/data",
104
+ "status": 200,
105
+ "expectBody": "{\"shared\":true}",
106
+ "expectHeaders": {
107
+ "vary": "origin"
108
+ }
109
+ },
110
+ {
111
+ "path": "/cors/data",
112
+ "status": 200,
113
+ "method": "HEAD",
114
+ "expectBody": "",
115
+ "expectHeaders": {
116
+ "vary": "origin"
117
+ }
118
+ },
119
+ {
120
+ "path": "/traced",
121
+ "status": 200,
122
+ "headers": {
123
+ "x-correlation-id": "trace-123"
124
+ },
125
+ "expectBody": "Traced",
126
+ "expectHeaders": {
127
+ "x-correlation-id": "trace-123"
128
+ }
129
+ },
130
+ {
131
+ "path": "/traced",
132
+ "status": 200,
133
+ "headers": {
134
+ "x-correlation-id": "not valid!"
135
+ },
136
+ "expectBody": "Traced"
137
+ },
138
+ {
139
+ "path": "/traced",
140
+ "status": 200,
141
+ "method": "HEAD",
142
+ "expectBody": ""
143
+ },
144
+ {
145
+ "path": "/maintenance",
146
+ "status": 503,
147
+ "expectBody": "Down for maintenance\n",
148
+ "expectHeaders": {
149
+ "retry-after": "120"
150
+ }
151
+ },
152
+ {
153
+ "path": "/maintenance",
154
+ "status": 200,
155
+ "method": "HEAD",
156
+ "headers": {
157
+ "x-maintenance-bypass": "let-me-in"
158
+ },
159
+ "expectBody": ""
160
+ },
161
+ {
162
+ "path": "/maintenance",
163
+ "status": 200,
164
+ "headers": {
165
+ "x-maintenance-bypass": "let-me-in"
166
+ },
167
+ "expectBody": "Still here"
168
+ },
169
+ {
170
+ "path": "/fragile",
171
+ "status": 200,
172
+ "headers": {
173
+ "x-correlation-id": "r-1"
174
+ },
175
+ "expectBody": "{\"healthy\":true}",
176
+ "expectHeaders": {
177
+ "x-correlation-id": "r-1"
178
+ }
179
+ },
180
+ {
181
+ "path": "/fragile?fail=true",
182
+ "status": 500,
183
+ "headers": {
184
+ "x-correlation-id": "r-2"
185
+ },
186
+ "expectBody": "{\"error\":\"Temporarily unavailable\",\"correlationId\":\"r-2\"}",
187
+ "expectHeaders": {
188
+ "cache-control": "no-store"
189
+ }
190
+ },
191
+ {
192
+ "path": "/fragile",
193
+ "status": 200,
194
+ "method": "HEAD",
195
+ "expectBody": ""
196
+ },
197
+ {
198
+ "path": "/fragile?fail=true",
199
+ "status": 500,
200
+ "method": "HEAD",
201
+ "expectBody": ""
202
+ },
203
+ {
204
+ "path": "/fragile?fail=perhaps",
205
+ "status": 400
206
+ },
207
+ {
208
+ "path": "/api/items",
209
+ "status": 200,
210
+ "expectBody": "{\"ok\":true,\"data\":[{\"id\":1,\"name\":\"first\"},{\"id\":2,\"name\":\"second\"}],\"meta\":{\"route\":\"/api/items\",\"count\":2}}"
211
+ },
212
+ {
213
+ "path": "/api/items",
214
+ "status": 200,
215
+ "method": "HEAD",
216
+ "expectBody": ""
217
+ },
218
+ {
219
+ "path": "/negotiated",
220
+ "status": 200,
221
+ "expectBody": "{\"service\":\"cookbook\",\"state\":\"ok\"}",
222
+ "expectHeaders": {
223
+ "vary": "accept"
224
+ }
225
+ },
226
+ {
227
+ "path": "/negotiated",
228
+ "status": 200,
229
+ "headers": {
230
+ "accept": "application/json"
231
+ },
232
+ "expectBody": "{\"service\":\"cookbook\",\"state\":\"ok\"}"
233
+ },
234
+ {
235
+ "path": "/negotiated",
236
+ "status": 200,
237
+ "headers": {
238
+ "accept": "text/plain, application/json;q=0.5"
239
+ },
240
+ "expectBody": "service: cookbook\nstate: ok\n",
241
+ "expectHeaders": {
242
+ "content-type": "text/plain; charset=utf-8"
243
+ }
244
+ },
245
+ {
246
+ "path": "/negotiated",
247
+ "status": 406,
248
+ "headers": {
249
+ "accept": "image/png"
250
+ }
251
+ },
252
+ {
253
+ "path": "/negotiated",
254
+ "status": 200,
255
+ "method": "HEAD",
256
+ "expectBody": ""
257
+ },
258
+ {
259
+ "path": "/resource",
260
+ "status": 200,
261
+ "expectBody": "{\"method\":\"GET\",\"tunneled\":false}"
262
+ },
263
+ {
264
+ "path": "/resource",
265
+ "status": 200,
266
+ "method": "HEAD",
267
+ "expectBody": ""
268
+ },
269
+ {
270
+ "path": "/resource",
271
+ "status": 200,
272
+ "method": "POST",
273
+ "expectBody": "{\"method\":\"POST\",\"tunneled\":false}"
274
+ },
275
+ {
276
+ "path": "/resource",
277
+ "status": 200,
278
+ "method": "POST",
279
+ "headers": {
280
+ "x-http-method-override": "delete"
281
+ },
282
+ "expectBody": "{\"method\":\"DELETE\",\"tunneled\":true}"
283
+ },
284
+ {
285
+ "path": "/resource",
286
+ "status": 405,
287
+ "method": "POST",
288
+ "headers": {
289
+ "x-http-method-override": "TRACE"
290
+ },
291
+ "expectHeaders": {
292
+ "allow": "PUT, PATCH, DELETE"
293
+ }
294
+ },
295
+ {
296
+ "path": "/resource",
297
+ "status": 200,
298
+ "method": "PUT",
299
+ "expectBody": "{\"method\":\"PUT\",\"tunneled\":false}"
300
+ },
301
+ {
302
+ "path": "/resource",
303
+ "status": 200,
304
+ "method": "PATCH",
305
+ "expectBody": "{\"method\":\"PATCH\",\"tunneled\":false}"
306
+ },
307
+ {
308
+ "path": "/resource",
309
+ "status": 200,
310
+ "method": "DELETE",
311
+ "expectBody": "{\"method\":\"DELETE\",\"tunneled\":false}"
312
+ },
313
+ {
314
+ "path": "/versioned",
315
+ "status": 200,
316
+ "expectBody": "{\"version\":3,\"items\":[\"alpha\",\"beta\"]}",
317
+ "expectHeaders": {
318
+ "etag": "W/\"b4124e8a\"",
319
+ "cache-control": "public, max-age=60"
320
+ }
321
+ },
322
+ {
323
+ "path": "/versioned",
324
+ "status": 304,
325
+ "headers": {
326
+ "if-none-match": "W/\"b4124e8a\""
327
+ },
328
+ "expectBody": "",
329
+ "expectHeaders": {
330
+ "etag": "W/\"b4124e8a\""
331
+ }
332
+ },
333
+ {
334
+ "path": "/versioned",
335
+ "status": 200,
336
+ "headers": {
337
+ "if-none-match": "W/\"stale\""
338
+ },
339
+ "expectHeaders": {
340
+ "etag": "W/\"b4124e8a\""
341
+ }
342
+ },
343
+ {
344
+ "path": "/versioned",
345
+ "status": 200,
346
+ "method": "HEAD",
347
+ "expectBody": "",
348
+ "expectHeaders": {
349
+ "etag": "W/\"b4124e8a\""
350
+ }
351
+ },
352
+ {
353
+ "path": "/experiment",
354
+ "status": 302,
355
+ "headers": {
356
+ "cookie": "bucket=a"
357
+ },
358
+ "expectHeaders": {
359
+ "location": "https://example.com/landing",
360
+ "vary": "cookie"
361
+ }
362
+ },
363
+ {
364
+ "path": "/experiment",
365
+ "status": 302,
366
+ "headers": {
367
+ "cookie": "theme=light; bucket=b"
368
+ },
369
+ "expectHeaders": {
370
+ "location": "https://example.com/landing-b",
371
+ "vary": "cookie"
372
+ }
373
+ },
374
+ {
375
+ "path": "/experiment",
376
+ "status": 302,
377
+ "expectHeaders": {
378
+ "vary": "cookie"
379
+ }
380
+ },
381
+ {
382
+ "path": "/experiment",
383
+ "status": 302,
384
+ "method": "HEAD",
385
+ "headers": {
386
+ "cookie": "bucket=a"
387
+ },
388
+ "expectHeaders": {
389
+ "location": "https://example.com/landing"
390
+ }
391
+ },
392
+ {
393
+ "path": "/welcome",
394
+ "status": 302,
395
+ "expectHeaders": {
396
+ "location": "https://example.com/en/welcome",
397
+ "vary": "accept-language"
398
+ }
399
+ },
400
+ {
401
+ "path": "/welcome",
402
+ "status": 302,
403
+ "headers": {
404
+ "accept-language": "de-DE,de;q=0.9,en;q=0.8"
405
+ },
406
+ "expectHeaders": {
407
+ "location": "https://example.com/de/welcome"
408
+ }
409
+ },
410
+ {
411
+ "path": "/welcome",
412
+ "status": 302,
413
+ "headers": {
414
+ "accept-language": "fr-CA"
415
+ },
416
+ "expectHeaders": {
417
+ "location": "https://example.com/fr/welcome"
418
+ }
419
+ },
420
+ {
421
+ "path": "/welcome",
422
+ "status": 302,
423
+ "headers": {
424
+ "accept-language": "ja"
425
+ },
426
+ "expectHeaders": {
427
+ "location": "https://example.com/en/welcome"
428
+ }
429
+ },
430
+ {
431
+ "path": "/welcome",
432
+ "status": 302,
433
+ "method": "HEAD",
434
+ "headers": {
435
+ "accept-language": "de"
436
+ },
437
+ "expectHeaders": {
438
+ "location": "https://example.com/de/welcome"
439
+ }
440
+ },
441
+ {
442
+ "path": "/downloads/report",
443
+ "status": 403
444
+ },
445
+ {
446
+ "path": "/downloads/report",
447
+ "status": 403,
448
+ "headers": {
449
+ "referer": "https://evil.example.net/page"
450
+ }
451
+ },
452
+ {
453
+ "path": "/downloads/report",
454
+ "status": 200,
455
+ "headers": {
456
+ "referer": "https://www.example.com/docs"
457
+ },
458
+ "expectBody": "URLCode guide\n",
459
+ "expectHeaders": {
460
+ "content-disposition": "attachment; filename=report.txt"
461
+ }
462
+ },
463
+ {
464
+ "path": "/downloads/report",
465
+ "status": 200,
466
+ "method": "HEAD",
467
+ "headers": {
468
+ "referer": "https://example.com/"
469
+ },
470
+ "expectBody": ""
471
+ },
472
+ {
473
+ "path": "/profile",
474
+ "status": 201,
475
+ "method": "POST",
476
+ "headers": {
477
+ "content-type": "application/json"
478
+ },
479
+ "body": "{\"name\":\"Ada\",\"age\":36}",
480
+ "expectBody": "{\"welcome\":\"Ada\",\"age\":36}"
481
+ },
482
+ {
483
+ "path": "/profile",
484
+ "status": 422,
485
+ "method": "POST",
486
+ "headers": {
487
+ "content-type": "application/json"
488
+ },
489
+ "body": "{\"name\":\"\",\"age\":-1,\"role\":\"x\"}",
490
+ "expectBody": "{\"errors\":[\"name must be 1-80 characters\",\"age must be an integer from 0 to 150\",\"unknown field role\"]}"
491
+ },
492
+ {
493
+ "path": "/profile",
494
+ "status": 400,
495
+ "method": "POST",
496
+ "headers": {
497
+ "content-type": "application/json"
498
+ },
499
+ "body": "["
500
+ },
501
+ {
502
+ "path": "/profile",
503
+ "status": 405
504
+ },
505
+ {
506
+ "path": "/inspect?topic=middleware",
507
+ "status": 200,
508
+ "expectBody": "Nothing to see"
509
+ },
510
+ {
511
+ "path": "/inspect?topic=middleware",
512
+ "status": 200,
513
+ "headers": {
514
+ "x-debug": "1",
515
+ "authorization": "Bearer hidden"
516
+ },
517
+ "expectHeaders": {
518
+ "cache-control": "no-store",
519
+ "content-type": "application/json"
520
+ }
521
+ },
522
+ {
523
+ "path": "/inspect",
524
+ "status": 200,
525
+ "method": "HEAD",
526
+ "expectBody": ""
527
+ }
528
+ ]
@@ -0,0 +1,127 @@
1
+ version: "1"
2
+ # Reusable middleware patterns, one route per module. Bindings are literal values
3
+ # here; production projects use {secret: name} with an operator grant instead.
4
+ # Rename or delete the routes you do not need; the modules are independent.
5
+ routes:
6
+ /api/private:
7
+ description: Bearer token gate with a constant-time comparison
8
+ env:
9
+ API_TOKEN: {value: cookbook-token}
10
+ middleware:
11
+ - source: middleware/auth.mjs
12
+ export: bearer
13
+ respond: {json: {private: true}}
14
+ /admin/panel:
15
+ description: HTTP Basic authentication decoded inside the guest
16
+ env:
17
+ ADMIN_USER: {value: admin}
18
+ ADMIN_PASSWORD: {value: cookbook-password}
19
+ middleware:
20
+ - source: middleware/auth.mjs
21
+ export: basic
22
+ respond: {text: Admin panel}
23
+ /cors/data:
24
+ description: CORS allowlist with preflight handled before the handler
25
+ methods: [GET, HEAD, OPTIONS]
26
+ env:
27
+ ALLOWED_ORIGINS: {value: https://app.example.com https://admin.example.com}
28
+ middleware:
29
+ - source: middleware/cors.mjs
30
+ respond: {json: {shared: true}}
31
+ /traced:
32
+ description: Caller correlation id and Server-Timing on every response
33
+ middleware:
34
+ - source: middleware/request-id.mjs
35
+ respond: {text: Traced}
36
+ /maintenance:
37
+ description: Kill switch returning 503 unless a bypass header is presented
38
+ env:
39
+ MAINTENANCE: {value: "true"}
40
+ MAINTENANCE_BYPASS: {value: let-me-in}
41
+ middleware:
42
+ - source: middleware/maintenance.mjs
43
+ respond: {text: Still here}
44
+ /fragile:
45
+ description: Error boundary turning a thrown exception into a JSON 500
46
+ parameters:
47
+ - name: fail
48
+ in: query
49
+ schema: {type: boolean, default: false}
50
+ middleware:
51
+ - source: middleware/request-id.mjs
52
+ - source: middleware/errors.mjs
53
+ function:
54
+ source: functions/fail.mjs
55
+ args:
56
+ fail: {from: query, name: fail}
57
+ /api/items:
58
+ description: JSON envelope around a function response
59
+ middleware:
60
+ - source: middleware/envelope.mjs
61
+ function: {source: functions/items.mjs}
62
+ /negotiated:
63
+ description: Accept-driven JSON or plain-text representation, 406 otherwise
64
+ middleware:
65
+ - source: middleware/negotiate.mjs
66
+ function: {source: functions/status.mjs}
67
+ /resource:
68
+ description: Method override tunneling PUT, PATCH or DELETE through POST
69
+ methods: [GET, HEAD, POST, PUT, PATCH, DELETE]
70
+ middleware:
71
+ - source: middleware/methods.mjs
72
+ export: override
73
+ function: {source: functions/resource.mjs}
74
+ /versioned:
75
+ description: Weak ETag and 304 for function output
76
+ middleware:
77
+ - source: middleware/etag.mjs
78
+ function: {source: functions/catalog.mjs}
79
+ /experiment:
80
+ description: Sticky A/B bucket cookie choosing between two destinations
81
+ env:
82
+ VARIANT_URL: {value: https://example.com/landing-b}
83
+ middleware:
84
+ - source: middleware/bucket.mjs
85
+ redirect: {url: https://example.com/landing}
86
+ /welcome:
87
+ description: Accept-Language redirect to a localized destination
88
+ env:
89
+ LOCALES: {value: en de fr}
90
+ SITE: {value: https://example.com}
91
+ middleware:
92
+ - source: middleware/locale.mjs
93
+ redirect: {url: https://example.com/en/welcome}
94
+ /downloads/report:
95
+ description: Referer allowlist in front of a native download
96
+ env:
97
+ ALLOWED_REFERERS: {value: example.com www.example.com}
98
+ middleware:
99
+ - source: middleware/referer.mjs
100
+ download:
101
+ file: public/guide.txt
102
+ filename: report.txt
103
+ contentType: text/plain
104
+ cacheControl: no-store
105
+ /profile:
106
+ description: Body validated once in middleware, parsed object passed through state
107
+ methods: [POST]
108
+ request:
109
+ body:
110
+ required: true
111
+ maxBytes: 4096
112
+ contentTypes: [application/json]
113
+ format: json
114
+ middleware:
115
+ - source: middleware/body.mjs
116
+ function: {source: functions/profile.mjs}
117
+ /inspect:
118
+ description: Authoring aid echoing inputs, args and redacted headers on demand
119
+ parameters:
120
+ - name: topic
121
+ in: query
122
+ schema: {type: string, default: routing}
123
+ env:
124
+ DEBUG: {value: "true"}
125
+ middleware:
126
+ - source: middleware/debug.mjs
127
+ respond: {text: Nothing to see}
@@ -0,0 +1,22 @@
1
+ # Protected download
2
+
3
+ `/downloads/report` serves `files/report.txt` as an attachment, but only after
4
+ the operator-installed `auth` extension authorizes the request (`auth: true`,
5
+ the short form of `policies.extensions.auth`). The file is
6
+ served natively: no guest code runs, and the response is forced to `no-store`.
7
+
8
+ Like the `authenticated-json-api` recipe, this project declares the extension
9
+ and needs an operator host file outside the project plus the canonical origin
10
+ for every command:
11
+
12
+ ```sh
13
+ urlcode validate --local --project . --host-file /operator/host.mjs --origin https://files.example.com
14
+ urlcode test --project . --host-file /operator/host.mjs --origin https://files.example.com
15
+ urlcode audit --project . --expect-routes 1 --host-file /operator/host.mjs --origin https://files.example.com
16
+ ```
17
+
18
+ Use the host file from the `authenticated-json-api` README with the config
19
+ schema accepting `realm: downloads`; the bundled fixtures expect the demo token
20
+ `demo-token`. A real deployment registers `urlcode-auth` instead. Replace
21
+ `files/report.txt` with the real attachment and adjust `filename` and
22
+ `contentType`. Cloudflare refuses extensions.
@@ -0,0 +1 @@
1
+ Quarterly report (placeholder). Replace this file with the real attachment.