@jimhoyd/urlcode 0.3.0 → 0.4.0-alpha.1
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/.claude/skills/urlcode-authoring/SKILL.md +106 -0
- package/.claude/skills/urlcode-operations/SKILL.md +114 -0
- package/.claude-plugin/marketplace.json +18 -0
- package/CONTRIBUTING.md +30 -2
- package/README.md +157 -230
- package/ROADMAP.md +85 -2
- package/SECURITY.md +8 -1
- package/dist/BUILD-MANIFEST.json +62 -32
- package/dist/adapters.js +4 -23
- package/dist/agent-lists.js +1 -1
- package/dist/agents-guide.js +113 -0
- package/dist/authoring-files.js +60 -0
- package/dist/authoring.js +11 -1
- package/dist/aws.js +4 -3
- package/dist/build-cloudflare.js +11 -24
- package/dist/bulk.js +37 -0
- package/dist/capabilities.js +208 -0
- package/dist/capability-query.js +72 -0
- package/dist/catalog.js +105 -0
- package/dist/cli.js +154 -15
- package/dist/client-address.js +1 -1
- package/dist/compliance-rules/baseline.js +8 -8
- package/dist/compliance-rules/privacy.js +3 -3
- package/dist/compliance-rules/strict.js +5 -5
- package/dist/conditions.js +88 -0
- package/dist/config.js +60 -4
- package/dist/context.js +156 -0
- package/dist/ecosystem-cli.js +88 -0
- package/dist/egress.js +98 -0
- package/dist/examples.js +92 -0
- package/dist/explain-cli.js +64 -0
- package/dist/explain.js +132 -0
- package/dist/extensions.js +172 -0
- package/dist/function-sources.js +15 -3
- package/dist/index.js +37 -0
- package/dist/init-with.js +165 -0
- package/dist/interchange-cli.js +42 -0
- package/dist/interchange.js +189 -0
- package/dist/link-cli.js +1 -1
- package/dist/management-policy.js +0 -1
- package/dist/manifest.js +111 -0
- package/dist/match.js +2 -2
- package/dist/mcp-authoring.js +147 -0
- package/dist/mcp.js +97 -0
- package/dist/observability.js +6 -0
- package/dist/operator-host.js +29 -0
- package/dist/plugins.js +12 -0
- package/dist/policies/agents.js +2 -2
- package/dist/policies/compression.js +2 -1
- package/dist/policies/security.js +0 -0
- package/dist/policies.js +1 -1
- package/dist/policy.js +29 -7
- package/dist/prerender.js +100 -41
- package/dist/project-tests.js +3 -3
- package/dist/provider-verification.js +92 -0
- package/dist/proxy.js +44 -0
- package/dist/readiness.js +5 -5
- package/dist/recipes.js +41 -0
- package/dist/route-diff.js +106 -0
- package/dist/router.js +42 -2
- package/dist/runtime.js +95 -14
- package/dist/schema-query.js +62 -0
- package/dist/signals.js +24 -0
- package/dist/site.js +0 -0
- package/dist/tooling.js +96 -0
- package/dist/types/adapters.d.ts +7 -4
- package/dist/types/agent-lists.d.ts +0 -1
- package/dist/types/agents-guide.d.ts +17 -0
- package/dist/types/authoring-files.d.ts +10 -0
- package/dist/types/aws.d.ts +3 -1
- package/dist/types/build-cloudflare.d.ts +1 -0
- package/dist/types/bulk.d.ts +27 -0
- package/dist/types/capabilities.d.ts +55 -0
- package/dist/types/capability-query.d.ts +24 -0
- package/dist/types/catalog.d.ts +65 -0
- package/dist/types/client-address.d.ts +0 -1
- package/dist/types/compliance-rules/baseline.d.ts +1 -9
- package/dist/types/compliance-rules/privacy.d.ts +1 -4
- package/dist/types/compliance-rules/strict.d.ts +0 -5
- package/dist/types/conditions.d.ts +19 -0
- package/dist/types/config.d.ts +20 -2
- package/dist/types/context.d.ts +65 -0
- package/dist/types/ecosystem-cli.d.ts +17 -0
- package/dist/types/egress.d.ts +46 -0
- package/dist/types/examples.d.ts +50 -0
- package/dist/types/explain-cli.d.ts +11 -0
- package/dist/types/explain.d.ts +95 -0
- package/dist/types/extensions.d.ts +122 -0
- package/dist/types/function-sources.d.ts +5 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/init-with.d.ts +30 -0
- package/dist/types/interchange-cli.d.ts +16 -0
- package/dist/types/interchange.d.ts +42 -0
- package/dist/types/link-cli.d.ts +2 -1
- package/dist/types/management-policy.d.ts +0 -1
- package/dist/types/manifest.d.ts +81 -0
- package/dist/types/match.d.ts +1 -0
- package/dist/types/mcp-authoring.d.ts +92 -0
- package/dist/types/mcp.d.ts +12 -0
- package/dist/types/observability.d.ts +2 -0
- package/dist/types/operator-host.d.ts +8 -0
- package/dist/types/plugins.d.ts +2 -0
- package/dist/types/policies/agents.d.ts +0 -2
- package/dist/types/policies/compression.d.ts +2 -0
- package/dist/types/policies/security.d.ts +0 -1
- package/dist/types/policy.d.ts +15 -4
- package/dist/types/project-tests.d.ts +3 -1
- package/dist/types/provider-verification.d.ts +53 -0
- package/dist/types/proxy.d.ts +21 -0
- package/dist/types/readiness.d.ts +1 -1
- package/dist/types/recipes.d.ts +30 -0
- package/dist/types/route-diff.d.ts +27 -0
- package/dist/types/runtime.d.ts +11 -0
- package/dist/types/schema-query.d.ts +12 -0
- package/dist/types/signals.d.ts +25 -0
- package/dist/types/site.d.ts +0 -1
- package/dist/types/tooling.d.ts +115 -0
- package/dist/types/types.d.ts +57 -0
- package/dist/types/typescript-authoring.d.ts +12 -0
- package/dist/types/vercel.d.ts +3 -1
- package/dist/types/verify-deployment.d.ts +47 -0
- package/dist/types.js +21 -2
- package/dist/typescript-authoring.js +104 -0
- package/dist/vercel.js +4 -3
- package/dist/verify-deployment.js +270 -0
- package/docs/AI-AUTHORING.md +130 -8
- package/docs/BULK.md +79 -0
- package/docs/CAPABILITIES.md +179 -0
- package/docs/CAPACITY.md +1 -1
- package/docs/CI.md +142 -0
- package/docs/CONDITIONS.md +74 -0
- package/docs/DEPLOYMENT-CHECKS.md +108 -0
- package/docs/DYNAMIC-LINKS.md +18 -518
- package/docs/EGRESS.md +125 -0
- package/docs/EXTENSIONS.md +226 -0
- package/docs/FRAMEWORK.md +182 -0
- package/docs/INSTALL.md +45 -7
- package/docs/INTERCHANGE.md +134 -0
- package/docs/MIDDLEWARE-EXAMPLES.md +75 -0
- package/docs/MIDDLEWARE.md +2 -0
- package/docs/NEXT-PHASE-PLAN.md +90 -0
- package/docs/NEXT-STEPS.md +415 -0
- package/docs/OBSERVABILITY.md +4 -2
- package/docs/OPERATIONAL-PROOF.md +4 -1
- package/docs/OPERATIONS.md +6 -3
- package/docs/PLUGINS.md +37 -0
- package/docs/POLICIES.md +12 -309
- package/docs/PRERENDER.md +40 -0
- package/docs/PROJECT-DIRECTION.md +42 -0
- package/docs/PROVIDER-VERIFICATION.md +84 -0
- package/docs/READINESS.md +21 -1
- package/docs/README.md +82 -31
- package/docs/RECIPES.md +99 -0
- package/docs/RELEASE-READINESS.md +11 -9
- package/docs/RELEASE-SECURITY.md +27 -4
- package/docs/SECURITY-AUDIT.md +1 -1
- package/docs/SPECIFICATION.md +95 -8
- package/docs/SPIKE-BUSINESS-SUITE.md +1013 -0
- package/docs/SPIKE-EXTENSION-MODEL.md +419 -0
- package/docs/SPIKE-EXTENSIONS.md +1 -0
- package/docs/SPIKE-LAMBDA-COMPILE.md +199 -0
- package/docs/STANDARDS.md +150 -142
- package/docs/STARTERS.md +21 -1
- package/docs/TOOLING.md +291 -0
- package/docs/TYPESCRIPT-AUTHORING.md +67 -0
- package/docs/TYPESCRIPT.md +1 -1
- package/docs/USABILITY-REVIEW.md +123 -0
- package/docs/YAML-GUIDE.md +18 -479
- package/docs/YAML-REFERENCE.md +127 -16
- package/docs/links/cli.md +110 -0
- package/docs/links/limits.md +175 -0
- package/docs/links/management-api.md +80 -0
- package/docs/links/pools.md +75 -0
- package/docs/links/setup.md +135 -0
- package/docs/policies/agents.md +1 -1
- package/docs/policies/contract.md +52 -0
- package/docs/policies/hardened.md +56 -0
- package/docs/policies/interoperability.md +169 -0
- package/docs/policies/operations.md +45 -0
- package/docs/yaml/assets.md +36 -0
- package/docs/yaml/conditions.md +20 -0
- package/docs/yaml/functions.md +160 -0
- package/docs/yaml/links.md +30 -0
- package/docs/yaml/middleware.md +29 -0
- package/docs/yaml/organization.md +74 -0
- package/docs/yaml/policies.md +37 -0
- package/docs/yaml/redirects.md +64 -0
- package/docs/yaml/responses.md +57 -0
- package/docs/yaml/site.md +24 -0
- package/examples/assets/example.yaml +17 -0
- package/examples/aws/example.yaml +20 -0
- package/examples/cloudflare/example.yaml +19 -0
- package/examples/compliance/example.yaml +11 -0
- package/examples/conditions/README.md +12 -0
- package/examples/conditions/example.yaml +19 -0
- package/examples/conditions/tests/requests.json +13 -0
- package/examples/conditions/urlcode.yaml +24 -0
- package/examples/cookbook/README.md +8 -4
- package/examples/cookbook/example.yaml +17 -0
- package/examples/cookbook/functions/catalog.mjs +3 -0
- package/examples/cookbook/functions/fail.mjs +4 -0
- package/examples/cookbook/functions/items.mjs +3 -0
- package/examples/cookbook/functions/profile.mjs +3 -0
- package/examples/cookbook/functions/resource.mjs +3 -0
- package/examples/cookbook/functions/status.mjs +3 -0
- package/examples/cookbook/middleware/auth.mjs +48 -0
- package/examples/cookbook/middleware/body.mjs +15 -0
- package/examples/cookbook/middleware/bucket.mjs +19 -0
- package/examples/cookbook/middleware/cors.mjs +21 -0
- package/examples/cookbook/middleware/debug.mjs +13 -0
- package/examples/cookbook/middleware/envelope.mjs +11 -0
- package/examples/cookbook/middleware/errors.mjs +11 -0
- package/examples/cookbook/middleware/etag.mjs +18 -0
- package/examples/cookbook/middleware/locale.mjs +16 -0
- package/examples/cookbook/middleware/maintenance.mjs +10 -0
- package/examples/cookbook/middleware/methods.mjs +15 -0
- package/examples/cookbook/middleware/negotiate.mjs +20 -0
- package/examples/cookbook/middleware/referer.mjs +12 -0
- package/examples/cookbook/middleware/request-id.mjs +16 -0
- package/examples/cookbook/route-index.json +676 -0
- package/examples/cookbook/routes/middleware.yaml +126 -0
- package/examples/cookbook/tests/requests.json +526 -0
- package/examples/cookbook/urlcode.yaml +1 -0
- package/examples/egress/README.md +22 -0
- package/examples/egress/example.yaml +19 -0
- package/examples/egress/urlcode.yaml +19 -0
- package/examples/extensions/README.md +7 -0
- package/examples/extensions/example.yaml +21 -0
- package/examples/extensions/urlcode.yaml +25 -0
- package/examples/live-links/example.yaml +21 -0
- package/examples/monitoring/example.yaml +8 -0
- package/examples/prerender/example.yaml +16 -0
- package/examples/provider-conformance/README.md +12 -0
- package/examples/provider-conformance/example.yaml +14 -0
- package/examples/provider-conformance/urlcode.yaml +34 -0
- package/examples/tunnel/example.yaml +8 -0
- package/examples/vercel/example.yaml +19 -0
- package/llms-full.txt +2709 -0
- package/llms.txt +48 -19
- package/package.json +29 -7
- package/packaging/claude-plugin/.claude-plugin/plugin.json +19 -0
- package/packaging/claude-plugin/skills/urlcode-authoring/SKILL.md +106 -0
- package/packaging/claude-plugin/skills/urlcode-operations/SKILL.md +114 -0
- package/recipes/authenticated-json-api/README.md +51 -0
- package/recipes/authenticated-json-api/functions/profile.mjs +5 -0
- package/recipes/authenticated-json-api/recipe.yaml +34 -0
- package/recipes/authenticated-json-api/tests/requests.json +39 -0
- package/recipes/authenticated-json-api/urlcode.yaml +12 -0
- package/recipes/contact-form/README.md +25 -0
- package/recipes/contact-form/functions/contact.mjs +17 -0
- package/recipes/contact-form/recipe.yaml +33 -0
- package/recipes/contact-form/tests/requests.json +47 -0
- package/recipes/contact-form/urlcode.yaml +18 -0
- package/recipes/cors-api/README.md +16 -0
- package/recipes/cors-api/functions/items.mjs +3 -0
- package/recipes/cors-api/middleware/cors.mjs +21 -0
- package/recipes/cors-api/recipe.yaml +26 -0
- package/recipes/cors-api/tests/requests.json +65 -0
- package/recipes/cors-api/urlcode.yaml +12 -0
- package/recipes/health-page/README.md +13 -0
- package/recipes/health-page/recipe.yaml +23 -0
- package/recipes/health-page/tests/requests.json +36 -0
- package/recipes/health-page/urlcode.yaml +19 -0
- package/recipes/json-api/README.md +6 -0
- package/recipes/json-api/functions/echo.mjs +3 -0
- package/recipes/json-api/recipe.yaml +25 -0
- package/recipes/json-api/tests/requests.json +34 -0
- package/recipes/json-api/urlcode.yaml +12 -0
- package/recipes/middleware/README.md +34 -0
- package/recipes/middleware/functions/catalog.mjs +3 -0
- package/recipes/middleware/functions/fail.mjs +4 -0
- package/recipes/middleware/functions/items.mjs +3 -0
- package/recipes/middleware/functions/profile.mjs +3 -0
- package/recipes/middleware/functions/resource.mjs +3 -0
- package/recipes/middleware/functions/status.mjs +3 -0
- package/recipes/middleware/middleware/auth.mjs +48 -0
- package/recipes/middleware/middleware/body.mjs +15 -0
- package/recipes/middleware/middleware/bucket.mjs +19 -0
- package/recipes/middleware/middleware/cors.mjs +21 -0
- package/recipes/middleware/middleware/debug.mjs +13 -0
- package/recipes/middleware/middleware/envelope.mjs +11 -0
- package/recipes/middleware/middleware/errors.mjs +11 -0
- package/recipes/middleware/middleware/etag.mjs +18 -0
- package/recipes/middleware/middleware/locale.mjs +16 -0
- package/recipes/middleware/middleware/maintenance.mjs +10 -0
- package/recipes/middleware/middleware/methods.mjs +15 -0
- package/recipes/middleware/middleware/negotiate.mjs +20 -0
- package/recipes/middleware/middleware/referer.mjs +12 -0
- package/recipes/middleware/middleware/request-id.mjs +16 -0
- package/recipes/middleware/public/guide.txt +1 -0
- package/recipes/middleware/recipe.yaml +50 -0
- package/recipes/middleware/tests/requests.json +528 -0
- package/recipes/middleware/urlcode.yaml +127 -0
- package/recipes/protected-download/README.md +22 -0
- package/recipes/protected-download/files/report.txt +1 -0
- package/recipes/protected-download/recipe.yaml +31 -0
- package/recipes/protected-download/tests/requests.json +32 -0
- package/recipes/protected-download/urlcode.yaml +15 -0
- package/recipes/redirect/README.md +7 -0
- package/recipes/redirect/recipe.yaml +25 -0
- package/recipes/redirect/tests/requests.json +19 -0
- package/recipes/redirect/urlcode.yaml +9 -0
- package/recipes/static-plus-api/README.md +15 -0
- package/recipes/static-plus-api/functions/info.mjs +3 -0
- package/recipes/static-plus-api/public/assets/index.html +3 -0
- package/recipes/static-plus-api/public/assets/site.css +1 -0
- package/recipes/static-plus-api/public/index.html +8 -0
- package/recipes/static-plus-api/recipe.yaml +29 -0
- package/recipes/static-plus-api/tests/requests.json +56 -0
- package/recipes/static-plus-api/urlcode.yaml +23 -0
- package/recipes/typescript/README.md +7 -0
- package/recipes/typescript/functions/hello.ts +5 -0
- package/recipes/typescript/recipe.yaml +23 -0
- package/recipes/typescript/tests/requests.json +18 -0
- package/recipes/typescript/urlcode.yaml +5 -0
- package/recipes/webhook-receiver/README.md +16 -0
- package/recipes/webhook-receiver/functions/receive.mjs +16 -0
- package/recipes/webhook-receiver/recipe.yaml +26 -0
- package/recipes/webhook-receiver/tests/requests.json +59 -0
- package/recipes/webhook-receiver/urlcode.yaml +16 -0
- package/schemas/recipe.schema.json +138 -0
- package/schemas/urlcode.schema.json +656 -80
- package/skills/urlcode/SKILL.md +98 -0
- package/starters/default/.github/workflows/urlcode.yml +23 -0
- package/starters/default/.mcp.json +12 -0
- package/starters/default/AGENTS.md +79 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Language redirect from Accept-Language, like Next.js i18n middleware. Only
|
|
2
|
+
// languages listed in LOCALES are chosen; the native redirect is the default.
|
|
3
|
+
export default async function locale(request, context, next) {
|
|
4
|
+
const supported = (context.env.LOCALES || '').split(/\s+/).filter(Boolean);
|
|
5
|
+
const ranked = (request.headers.get('accept-language') || '').split(',').map((part, index) => {
|
|
6
|
+
const [tag, ...params] = part.trim().split(';');
|
|
7
|
+
const q = params.map(p => p.trim()).find(p => p.startsWith('q='));
|
|
8
|
+
return {lang: tag.trim().toLowerCase().split('-')[0], q: q ? Number(q.slice(2)) || 0 : 1, index};
|
|
9
|
+
}).filter(p => p.q > 0).sort((a, b) => b.q - a.q || a.index - b.index);
|
|
10
|
+
const chosen = ranked.find(p => supported.includes(p.lang))?.lang;
|
|
11
|
+
const response = chosen && chosen !== supported[0]
|
|
12
|
+
? Response.redirect(context.env.SITE + '/' + chosen + '/welcome', 302)
|
|
13
|
+
: await next();
|
|
14
|
+
response.headers.set('vary', 'accept-language');
|
|
15
|
+
return response;
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// A kill switch: return 503 while MAINTENANCE is on, unless the caller presents
|
|
2
|
+
// the bypass token. Flip the binding and restart; no code change is needed.
|
|
3
|
+
export default async function maintenance(request, context, next) {
|
|
4
|
+
const active = context.env.MAINTENANCE === 'true';
|
|
5
|
+
const bypass = context.env.MAINTENANCE_BYPASS;
|
|
6
|
+
if (active && !(bypass && request.headers.get('x-maintenance-bypass') === bypass)) {
|
|
7
|
+
return new Response('Down for maintenance\n', {status: 503, headers: {'retry-after': '120', 'cache-control': 'no-store'}});
|
|
8
|
+
}
|
|
9
|
+
return next();
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Method override for clients that can only send POST (Express method-override).
|
|
2
|
+
// The route still declares every real method; only a bounded set may be tunneled.
|
|
3
|
+
const tunnelable = ['PUT', 'PATCH', 'DELETE'];
|
|
4
|
+
export async function override(request, context, next) {
|
|
5
|
+
const requested = (request.headers.get('x-http-method-override') || '').toUpperCase();
|
|
6
|
+
if (request.method === 'POST' && requested) {
|
|
7
|
+
if (!tunnelable.includes(requested)) {
|
|
8
|
+
return new Response('Method override not allowed\n', {status: 405, headers: {allow: tunnelable.join(', ')}});
|
|
9
|
+
}
|
|
10
|
+
context.state.method = requested;
|
|
11
|
+
} else {
|
|
12
|
+
context.state.method = request.method;
|
|
13
|
+
}
|
|
14
|
+
return next();
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Content negotiation in the spirit of Express res.format. The handler always
|
|
2
|
+
// produces JSON; this converts it to plain text when the client prefers that.
|
|
3
|
+
function preferences(accept) {
|
|
4
|
+
return (accept || '*/*').split(',').map((part, index) => {
|
|
5
|
+
const [type, ...params] = part.trim().split(';');
|
|
6
|
+
const q = params.map(p => p.trim()).find(p => p.startsWith('q='));
|
|
7
|
+
return {type: type.trim().toLowerCase(), q: q ? Number(q.slice(2)) || 0 : 1, index};
|
|
8
|
+
}).filter(p => p.q > 0).sort((a, b) => b.q - a.q || a.index - b.index);
|
|
9
|
+
}
|
|
10
|
+
export default async function negotiate(request, context, next) {
|
|
11
|
+
const ranked = preferences(request.headers.get('accept'));
|
|
12
|
+
const choice = ranked.find(p => ['application/json', 'text/plain', 'application/*', 'text/*', '*/*'].includes(p.type));
|
|
13
|
+
if (!choice) return new Response('Not acceptable: application/json or text/plain\n', {status: 406});
|
|
14
|
+
const response = await next();
|
|
15
|
+
response.headers.set('vary', 'accept');
|
|
16
|
+
if (!response.ok || !['text/plain', 'text/*'].includes(choice.type)) return response;
|
|
17
|
+
const value = await response.json();
|
|
18
|
+
const lines = Object.entries(value).map(([key, item]) => key + ': ' + String(item)).join('\n') + '\n';
|
|
19
|
+
return new Response(lines, {status: response.status, headers: {...Object.fromEntries(response.headers), 'content-type': 'text/plain; charset=utf-8'}});
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Hotlink protection for a download: the Referer host must be on the allowlist.
|
|
2
|
+
// Referers are advisory, so this deters casual embedding rather than securing anything.
|
|
3
|
+
function host(referer) {
|
|
4
|
+
const match = /^https?:\/\/([^/:?#]+)/i.exec(referer || '');
|
|
5
|
+
return match ? match[1].toLowerCase() : null;
|
|
6
|
+
}
|
|
7
|
+
export default async function referer(request, context, next) {
|
|
8
|
+
const allowed = (context.env.ALLOWED_REFERERS || '').split(/\s+/).filter(Boolean);
|
|
9
|
+
const from = host(request.headers.get('referer'));
|
|
10
|
+
if (from === null || !allowed.includes(from)) return new Response('Direct download links are not permitted\n', {status: 403});
|
|
11
|
+
return next();
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Correlation id and timing headers (Hono requestId/timing, Express response-time).
|
|
2
|
+
// The runtime already stamps its own x-request-id on every reply; this carries the
|
|
3
|
+
// caller's id instead so a client can match its logs to yours. The guest has no
|
|
4
|
+
// crypto, so a generated id is a trace label, never a secret.
|
|
5
|
+
const validId = /^[A-Za-z0-9._-]{1,64}$/;
|
|
6
|
+
export default async function correlation(request, context, next) {
|
|
7
|
+
const started = Date.now();
|
|
8
|
+
const incoming = request.headers.get('x-correlation-id');
|
|
9
|
+
context.state.correlationId = incoming !== null && validId.test(incoming)
|
|
10
|
+
? incoming
|
|
11
|
+
: started.toString(36) + '-' + Math.floor(Math.random() * 0xffffffff).toString(36);
|
|
12
|
+
const response = await next();
|
|
13
|
+
response.headers.set('x-correlation-id', context.state.correlationId);
|
|
14
|
+
response.headers.set('server-timing', 'app;dur=' + (Date.now() - started));
|
|
15
|
+
return response;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
URLCode guide
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
id: middleware
|
|
2
|
+
description: Fourteen reusable middleware patterns around fifteen routes, mirroring the cookbook's middleware modules.
|
|
3
|
+
tags: [middleware, auth, bearer, basic, cors, tracing, request-id, errors, etag, caching, maintenance, negotiation, locale, referer, method-override, envelope, validation, debug, bucket, experiment]
|
|
4
|
+
complexity: advanced
|
|
5
|
+
capabilities: [bindings, download, enabled, function, methods, middleware, parameters, redirect, request.body, respond]
|
|
6
|
+
targets: {self-hosted: compatible, aws: refused, vercel: refused, cloudflare: refused}
|
|
7
|
+
routes: 15
|
|
8
|
+
inputs:
|
|
9
|
+
- name: credentials
|
|
10
|
+
file: urlcode.yaml
|
|
11
|
+
description: The literal demo token and password bound as env values; bind real secrets through operator-granted secrets instead.
|
|
12
|
+
- name: allowlists
|
|
13
|
+
file: middleware/cors.mjs
|
|
14
|
+
description: Allowed browser origins here and the referers, locales and buckets in the sibling modules.
|
|
15
|
+
files:
|
|
16
|
+
- urlcode.yaml
|
|
17
|
+
- middleware/auth.mjs
|
|
18
|
+
- middleware/body.mjs
|
|
19
|
+
- middleware/bucket.mjs
|
|
20
|
+
- middleware/cors.mjs
|
|
21
|
+
- middleware/debug.mjs
|
|
22
|
+
- middleware/envelope.mjs
|
|
23
|
+
- middleware/errors.mjs
|
|
24
|
+
- middleware/etag.mjs
|
|
25
|
+
- middleware/locale.mjs
|
|
26
|
+
- middleware/maintenance.mjs
|
|
27
|
+
- middleware/methods.mjs
|
|
28
|
+
- middleware/negotiate.mjs
|
|
29
|
+
- middleware/referer.mjs
|
|
30
|
+
- middleware/request-id.mjs
|
|
31
|
+
- functions/catalog.mjs
|
|
32
|
+
- functions/fail.mjs
|
|
33
|
+
- functions/items.mjs
|
|
34
|
+
- functions/profile.mjs
|
|
35
|
+
- functions/resource.mjs
|
|
36
|
+
- functions/status.mjs
|
|
37
|
+
- public/guide.txt
|
|
38
|
+
- tests/requests.json
|
|
39
|
+
- README.md
|
|
40
|
+
tests:
|
|
41
|
+
fixtures: tests/requests.json
|
|
42
|
+
commands:
|
|
43
|
+
- urlcode validate --local --project .
|
|
44
|
+
- urlcode test --project .
|
|
45
|
+
- urlcode audit --project . --expect-routes 15
|
|
46
|
+
behavior:
|
|
47
|
+
- /api/private answers 401 without the bearer token and JSON with it
|
|
48
|
+
- OPTIONS /cors/data from an allowed origin answers 204 with CORS headers
|
|
49
|
+
- /maintenance answers 503; /fragile?fail=true answers a JSON error carrying the correlation id
|
|
50
|
+
- /versioned answers a weak ETag and 304 on a matching If-None-Match
|
|
@@ -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
|
+
]
|