@jimhoyd/urlcode 0.3.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/CONTRIBUTING.md +80 -0
- package/LICENSE +202 -0
- package/NOTICE +20 -0
- package/README.md +342 -0
- package/ROADMAP.md +248 -0
- package/SECURITY.md +40 -0
- package/data/agents/LICENSES/ai-robots-txt.txt +24 -0
- package/data/agents/LICENSES/crawler-user-agents.txt +23 -0
- package/data/agents/ai-crawlers.json +1240 -0
- package/data/agents/crawlers.json +10515 -0
- package/data/agents/index.d.ts +3 -0
- package/data/agents/index.js +2453 -0
- package/data/agents/monitoring.json +1520 -0
- package/data/agents/seo.json +3865 -0
- package/dist/BUILD-MANIFEST.json +60 -0
- package/dist/adapters.js +59 -0
- package/dist/agent-lists.js +59 -0
- package/dist/assets.js +129 -0
- package/dist/authoring.js +68 -0
- package/dist/aws.js +110 -0
- package/dist/build-cloudflare.js +164 -0
- package/dist/cli.js +185 -0
- package/dist/client-address.js +85 -0
- package/dist/cloudflare.js +165 -0
- package/dist/compliance-rules/baseline.js +98 -0
- package/dist/compliance-rules/privacy.js +38 -0
- package/dist/compliance-rules/shared.js +62 -0
- package/dist/compliance-rules/strict.js +61 -0
- package/dist/compliance.js +219 -0
- package/dist/config-worker.js +9 -0
- package/dist/config.js +172 -0
- package/dist/errors.js +8 -0
- package/dist/function-sources.js +54 -0
- package/dist/function-worker.js +105 -0
- package/dist/functions.js +174 -0
- package/dist/guest-api.js +114 -0
- package/dist/header-validation.js +18 -0
- package/dist/http-policy.js +74 -0
- package/dist/http-response.js +84 -0
- package/dist/index.js +11 -0
- package/dist/link-api.js +136 -0
- package/dist/link-cli.js +141 -0
- package/dist/link-events.js +76 -0
- package/dist/link-records.js +31 -0
- package/dist/link-store-worker.js +150 -0
- package/dist/link-store.js +250 -0
- package/dist/logging.js +22 -0
- package/dist/management-policy.js +41 -0
- package/dist/match.js +124 -0
- package/dist/observability.js +242 -0
- package/dist/plugins.js +74 -0
- package/dist/policies/agents.js +248 -0
- package/dist/policies/cache.js +297 -0
- package/dist/policies/compression.js +187 -0
- package/dist/policies/security.js +0 -0
- package/dist/policies/throttle.js +131 -0
- package/dist/policies.js +142 -0
- package/dist/policy.js +55 -0
- package/dist/prerender.js +165 -0
- package/dist/project-tests.js +23 -0
- package/dist/readiness.js +216 -0
- package/dist/router.js +166 -0
- package/dist/runtime.js +244 -0
- package/dist/scaffold.js +0 -0
- package/dist/scripts/operational-drills.js +75 -0
- package/dist/server.js +270 -0
- package/dist/site.js +0 -0
- package/dist/sqlite-version.js +6 -0
- package/dist/types/adapters.d.ts +12 -0
- package/dist/types/agent-lists.d.ts +5 -0
- package/dist/types/assets.d.ts +13 -0
- package/dist/types/authoring.d.ts +2 -0
- package/dist/types/aws.d.ts +35 -0
- package/dist/types/build-cloudflare.d.ts +14 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/client-address.d.ts +9 -0
- package/dist/types/cloudflare.d.ts +75 -0
- package/dist/types/compliance-rules/baseline.d.ts +12 -0
- package/dist/types/compliance-rules/privacy.d.ts +6 -0
- package/dist/types/compliance-rules/shared.d.ts +24 -0
- package/dist/types/compliance-rules/strict.d.ts +9 -0
- package/dist/types/compliance.d.ts +119 -0
- package/dist/types/config-worker.d.ts +1 -0
- package/dist/types/config.d.ts +21 -0
- package/dist/types/errors.d.ts +7 -0
- package/dist/types/function-sources.d.ts +21 -0
- package/dist/types/function-worker.d.ts +1 -0
- package/dist/types/functions.d.ts +92 -0
- package/dist/types/guest-api.d.ts +16 -0
- package/dist/types/header-validation.d.ts +2 -0
- package/dist/types/http-policy.d.ts +39 -0
- package/dist/types/http-response.d.ts +43 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/link-api.d.ts +30 -0
- package/dist/types/link-cli.d.ts +36 -0
- package/dist/types/link-events.d.ts +27 -0
- package/dist/types/link-records.d.ts +11 -0
- package/dist/types/link-store-worker.d.ts +1 -0
- package/dist/types/link-store.d.ts +130 -0
- package/dist/types/logging.d.ts +9 -0
- package/dist/types/management-policy.d.ts +9 -0
- package/dist/types/match.d.ts +81 -0
- package/dist/types/observability.d.ts +104 -0
- package/dist/types/plugins.d.ts +27 -0
- package/dist/types/policies/agents.d.ts +86 -0
- package/dist/types/policies/cache.d.ts +82 -0
- package/dist/types/policies/compression.d.ts +41 -0
- package/dist/types/policies/security.d.ts +37 -0
- package/dist/types/policies/throttle.d.ts +55 -0
- package/dist/types/policies.d.ts +36 -0
- package/dist/types/policy.d.ts +21 -0
- package/dist/types/prerender.d.ts +31 -0
- package/dist/types/project-tests.d.ts +13 -0
- package/dist/types/readiness.d.ts +121 -0
- package/dist/types/router.d.ts +11 -0
- package/dist/types/runtime.d.ts +91 -0
- package/dist/types/scaffold.d.ts +17 -0
- package/dist/types/server.d.ts +37 -0
- package/dist/types/site.d.ts +12 -0
- package/dist/types/sqlite-version.d.ts +1 -0
- package/dist/types/types.d.ts +332 -0
- package/dist/types/vercel.d.ts +12 -0
- package/dist/types.js +177 -0
- package/dist/vercel.js +65 -0
- package/docs/AI-AUTHORING.md +113 -0
- package/docs/ASSETS.md +106 -0
- package/docs/AWS.md +77 -0
- package/docs/BEST-PRACTICES.md +267 -0
- package/docs/CAPACITY.md +208 -0
- package/docs/CLOUDFLARE.md +110 -0
- package/docs/COMPLIANCE.md +242 -0
- package/docs/DYNAMIC-LINKS.md +561 -0
- package/docs/FUNCTION-SECURITY.md +113 -0
- package/docs/HTTP.md +129 -0
- package/docs/INSTALL.md +90 -0
- package/docs/LOAD-TESTING.md +91 -0
- package/docs/LOCAL-DEVELOPMENT.md +99 -0
- package/docs/MANAGEMENT-SECURITY.md +82 -0
- package/docs/MIDDLEWARE.md +83 -0
- package/docs/MONITORING.md +132 -0
- package/docs/OBSERVABILITY.md +229 -0
- package/docs/OPERATIONAL-PROOF.md +42 -0
- package/docs/OPERATIONS.md +207 -0
- package/docs/ORGANIZATION.md +135 -0
- package/docs/PERFORMANCE.md +72 -0
- package/docs/PLUGINS.md +234 -0
- package/docs/POLICIES.md +489 -0
- package/docs/PRERENDER.md +193 -0
- package/docs/PROJECT-DIRECTION.md +51 -0
- package/docs/READINESS.md +125 -0
- package/docs/README.md +58 -0
- package/docs/RELEASE-READINESS.md +95 -0
- package/docs/RELEASE-SECURITY.md +72 -0
- package/docs/RESILIENCE.md +160 -0
- package/docs/ROUTING.md +95 -0
- package/docs/SANDBOX-REVIEW.md +59 -0
- package/docs/SCAFFOLDING.md +72 -0
- package/docs/SECURITY-AUDIT.md +124 -0
- package/docs/SITE.md +150 -0
- package/docs/SPECIFICATION.md +232 -0
- package/docs/SPIKE-EXTENSIONS.md +475 -0
- package/docs/STANDARDS.md +303 -0
- package/docs/STARTERS.md +51 -0
- package/docs/TUNNELS.md +75 -0
- package/docs/TYPESCRIPT.md +102 -0
- package/docs/VERCEL.md +107 -0
- package/docs/YAML-GUIDE.md +521 -0
- package/docs/YAML-REFERENCE.md +328 -0
- package/docs/policies/agents.md +182 -0
- package/docs/policies/cache.md +139 -0
- package/docs/policies/compression.md +168 -0
- package/docs/policies/security.md +160 -0
- package/docs/policies/throttle.md +103 -0
- package/examples/assets/.env.example +1 -0
- package/examples/assets/.gitattributes +2 -0
- package/examples/assets/Makefile +30 -0
- package/examples/assets/README.md +18 -0
- package/examples/assets/functions/hello.mjs +3 -0
- package/examples/assets/gitignore.template +7 -0
- package/examples/assets/public/about.html +2 -0
- package/examples/assets/public/assets/example.txt +1 -0
- package/examples/assets/public/guide.txt +1 -0
- package/examples/assets/tests/requests.json +44 -0
- package/examples/assets/urlcode.yaml +27 -0
- package/examples/aws/README.md +13 -0
- package/examples/aws/handler.mjs +5 -0
- package/examples/aws/public/index.html +3 -0
- package/examples/aws/public/notes.txt +1 -0
- package/examples/aws/template.yaml +33 -0
- package/examples/aws/tests/requests.json +9 -0
- package/examples/aws/urlcode.yaml +19 -0
- package/examples/cloudflare/README.md +18 -0
- package/examples/cloudflare/package.json +14 -0
- package/examples/cloudflare/tests/requests.json +9 -0
- package/examples/cloudflare/urlcode.yaml +24 -0
- package/examples/cloudflare/wrangler.toml +5 -0
- package/examples/compliance/README.md +20 -0
- package/examples/compliance/rules.mjs +65 -0
- package/examples/cookbook/README.md +21 -0
- package/examples/cookbook/functions/choice.mjs +4 -0
- package/examples/cookbook/functions/echo.mjs +3 -0
- package/examples/cookbook/functions/hello.mjs +3 -0
- package/examples/cookbook/functions/text.mjs +3 -0
- package/examples/cookbook/middleware/headers.mjs +6 -0
- package/examples/cookbook/public/about.html +1 -0
- package/examples/cookbook/public/assets/index.html +1 -0
- package/examples/cookbook/public/assets/site.css +1 -0
- package/examples/cookbook/public/favicon.svg +1 -0
- package/examples/cookbook/public/guide.txt +1 -0
- package/examples/cookbook/public/llms.txt +6 -0
- package/examples/cookbook/routes/code.yaml +55 -0
- package/examples/cookbook/routes/files.yaml +17 -0
- package/examples/cookbook/routes/policies.yaml +28 -0
- package/examples/cookbook/routes/redirects.yaml +38 -0
- package/examples/cookbook/routes/responses.yaml +26 -0
- package/examples/cookbook/tests/requests.json +254 -0
- package/examples/cookbook/urlcode.yaml +22 -0
- package/examples/live-links/README.md +11 -0
- package/examples/live-links/tests/requests.json +6 -0
- package/examples/live-links/urlcode.yaml +16 -0
- package/examples/monitoring/blackbox-jobs.yaml +37 -0
- package/examples/monitoring/prometheus-rules.yaml +88 -0
- package/examples/monitoring/prometheus-scrape.yaml +20 -0
- package/examples/monitoring/vector.toml +65 -0
- package/examples/prerender/README.md +48 -0
- package/examples/prerender/functions/page.mjs +6 -0
- package/examples/prerender/middleware/template.mjs +29 -0
- package/examples/prerender/prerender.d.mts +4 -0
- package/examples/prerender/prerender.mjs +63 -0
- package/examples/prerender/tests/requests.json +39 -0
- package/examples/prerender/urlcode.yaml +50 -0
- package/examples/tunnel/dev-with-ngrok.sh +61 -0
- package/examples/vercel/README.md +13 -0
- package/examples/vercel/api/index.js +5 -0
- package/examples/vercel/package.json +8 -0
- package/examples/vercel/public/index.html +3 -0
- package/examples/vercel/public/notes.txt +1 -0
- package/examples/vercel/tests/requests.json +48 -0
- package/examples/vercel/urlcode.yaml +19 -0
- package/examples/vercel/vercel.json +10 -0
- package/llms.txt +46 -0
- package/package.json +123 -0
- package/schemas/urlcode.schema.json +1230 -0
- package/starters/default/.gitattributes +1 -0
- package/starters/default/Makefile +30 -0
- package/starters/default/README.md +34 -0
- package/starters/default/functions/hello.mjs +3 -0
- package/starters/default/gitignore.template +8 -0
- package/starters/default/middleware/headers.mjs +6 -0
- package/starters/default/routes/functions.yaml +20 -0
- package/starters/default/routes/marketing/links.yaml +7 -0
- package/starters/default/starter.json +5 -0
- package/starters/default/tests/requests.json +56 -0
- package/starters/default/urlcode.yaml +8 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.DEFAULT_GOAL := help
|
|
2
|
+
|
|
3
|
+
# Install the runtime separately, or override: URLCODE='node /path/to/urlcode/src/cli.js'
|
|
4
|
+
URLCODE ?= urlcode
|
|
5
|
+
HOST ?= 127.0.0.1
|
|
6
|
+
PORT ?= 3000
|
|
7
|
+
|
|
8
|
+
.PHONY: help dev serve validate test doctor
|
|
9
|
+
help:
|
|
10
|
+
@echo "make dev Run this app with reload and .env.local"
|
|
11
|
+
@echo "make validate Validate this app and its local bindings"
|
|
12
|
+
@echo "make test Run this app's HTTP assertions"
|
|
13
|
+
@echo "make serve Run a fixed snapshot, without local dotenv"
|
|
14
|
+
@echo "make doctor Show runtime/platform details"
|
|
15
|
+
@echo "Options: PORT=3001 HOST=127.0.0.1 URLCODE=urlcode"
|
|
16
|
+
|
|
17
|
+
dev:
|
|
18
|
+
$(URLCODE) dev --project . --host "$(HOST)" --port "$(PORT)"
|
|
19
|
+
serve:
|
|
20
|
+
$(URLCODE) serve --project . --host "$(HOST)" --port "$(PORT)"
|
|
21
|
+
validate:
|
|
22
|
+
$(URLCODE) validate --local --project .
|
|
23
|
+
test:
|
|
24
|
+
$(URLCODE) test --project .
|
|
25
|
+
doctor:
|
|
26
|
+
$(URLCODE) doctor
|
|
27
|
+
|
|
28
|
+
.PHONY: routes audit benchmark
|
|
29
|
+
routes audit benchmark:
|
|
30
|
+
$(URLCODE) $@ --project . $(ARGS)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Your URLCode project
|
|
2
|
+
|
|
3
|
+
One starter: a URL that runs your function, and a regular redirect.
|
|
4
|
+
Created with `urlcode init ../my-links`. No template choice is needed.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
urlcode dev
|
|
8
|
+
# In another terminal:
|
|
9
|
+
urlcode test
|
|
10
|
+
urlcode audit --expect-routes 2
|
|
11
|
+
urlcode benchmark --requests 1000 --concurrency 2
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Visit http://127.0.0.1:3000/hello/Ada or http://127.0.0.1:3000/go.
|
|
15
|
+
`urlcode.yaml` loads `routes/functions.yaml` and `routes/marketing/links.yaml`.
|
|
16
|
+
Organize those files however you like; references are relative to the project root.
|
|
17
|
+
The function route uses `middleware/headers.mjs` to add a response header around
|
|
18
|
+
`await next()`. Edit or reuse it on other routes as needed.
|
|
19
|
+
GET/HEAD, redirect 302 and no-store defaults keep YAML short. Valid edits reload.
|
|
20
|
+
|
|
21
|
+
This app uses the runtime you installed separately (compatible with 0.1.0).
|
|
22
|
+
Without a global install, invoke `node /path/to/urlcode/src/cli.ts` instead of
|
|
23
|
+
`urlcode`. Optional Make shortcuts accept `URLCODE='node /path/to/urlcode/src/cli.ts'`.
|
|
24
|
+
For a cloneable project with a pinned npm runtime dependency, use
|
|
25
|
+
[urlcode-template](https://github.com/jimhoyd-com/urlcode-template). Both start
|
|
26
|
+
with the same two route examples. No runtime fork or provider account is needed.
|
|
27
|
+
|
|
28
|
+
Keep this app in your own Git repository. Secrets stay in ignored `.env.local`
|
|
29
|
+
or provider environment values, with external operator policy for function grants.
|
|
30
|
+
See [security](https://github.com/jimhoyd-com/urlcode/blob/main/docs/FUNCTION-SECURITY.md)
|
|
31
|
+
and [readiness](https://github.com/jimhoyd-com/urlcode/blob/main/docs/READINESS.md).
|
|
32
|
+
Add routes and assertions as your app grows; update the expected count deliberately.
|
|
33
|
+
URLCode is licensed under the Apache License 2.0. `gitignore.template` is initializer packaging
|
|
34
|
+
source and can be removed after `.gitignore` exists.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jimhoyd-com/urlcode/669632fb4f188f293a0f622847f87ee019c0627f/schemas/urlcode.schema.json
|
|
2
|
+
# File locations do not change route paths. GET/HEAD are the default methods.
|
|
3
|
+
version: "1"
|
|
4
|
+
routes:
|
|
5
|
+
# Your code runs when this URL is requested.
|
|
6
|
+
/hello/{name}:
|
|
7
|
+
parameters:
|
|
8
|
+
- name: name
|
|
9
|
+
in: path
|
|
10
|
+
required: true
|
|
11
|
+
schema: {type: string, minLength: 1, maxLength: 80}
|
|
12
|
+
middleware:
|
|
13
|
+
- source: middleware/headers.mjs
|
|
14
|
+
function:
|
|
15
|
+
source: functions/hello.mjs
|
|
16
|
+
args:
|
|
17
|
+
name: {from: path, name: name}
|
|
18
|
+
response:
|
|
19
|
+
headers:
|
|
20
|
+
X-Powered-By: URLCode
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jimhoyd-com/urlcode/669632fb4f188f293a0f622847f87ee019c0627f/schemas/urlcode.schema.json
|
|
2
|
+
version: "1"
|
|
3
|
+
routes:
|
|
4
|
+
# A regular redirect needs no custom code.
|
|
5
|
+
/go:
|
|
6
|
+
redirect:
|
|
7
|
+
url: https://example.com
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"path": "/hello/Ada",
|
|
4
|
+
"status": 200,
|
|
5
|
+
"expectBody": "{\"message\":\"Hello, Ada!\"}",
|
|
6
|
+
"expectHeaders": {
|
|
7
|
+
"x-powered-by": "URLCode",
|
|
8
|
+
"cache-control": "no-store",
|
|
9
|
+
"x-example-middleware": "active"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"path": "/hello/Ada",
|
|
14
|
+
"method": "HEAD",
|
|
15
|
+
"status": 200,
|
|
16
|
+
"expectBody": "",
|
|
17
|
+
"expectHeaders": {
|
|
18
|
+
"x-example-middleware": "active"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "/go",
|
|
23
|
+
"status": 302,
|
|
24
|
+
"expectHeaders": {
|
|
25
|
+
"location": "https://example.com/"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"path": "/go",
|
|
30
|
+
"method": "POST",
|
|
31
|
+
"status": 405,
|
|
32
|
+
"expectHeaders": {
|
|
33
|
+
"allow": "GET, HEAD"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"path": "/missing",
|
|
38
|
+
"status": 404
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"path": "/hello/Ada",
|
|
42
|
+
"method": "POST",
|
|
43
|
+
"status": 405,
|
|
44
|
+
"expectHeaders": {
|
|
45
|
+
"allow": "GET, HEAD"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"path": "/hello/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
50
|
+
"status": 400
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"path": "/hello/%ZZ",
|
|
54
|
+
"status": 400
|
|
55
|
+
}
|
|
56
|
+
]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/jimhoyd-com/urlcode/669632fb4f188f293a0f622847f87ee019c0627f/schemas/urlcode.schema.json
|
|
2
|
+
# Organize files however you like; list their paths from this project root.
|
|
3
|
+
version: "1"
|
|
4
|
+
dynamicLinks: false
|
|
5
|
+
includes:
|
|
6
|
+
- routes/functions.yaml
|
|
7
|
+
- routes/marketing/links.yaml
|
|
8
|
+
routes: {}
|