@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
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
URLCode is licensed under the Apache License 2.0. By submitting a contribution,
|
|
4
|
+
you agree that it may be distributed under that license and represent that you
|
|
5
|
+
have the right to submit it.
|
|
6
|
+
|
|
7
|
+
Use Node.js 22.18+ (the source is TypeScript, run directly through Node's type
|
|
8
|
+
stripping; CI targets 22, 24 and 26). Installed packages still run on 22.13+:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
make dev # installs dependencies and starts the watched function/redirect demo
|
|
12
|
+
# In another terminal:
|
|
13
|
+
make verify
|
|
14
|
+
make test-package
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Without Make, use `npm ci`, `npm run dev`, `npm run verify` and
|
|
18
|
+
`npm run test:package`. See [local development](docs/LOCAL-DEVELOPMENT.md) for
|
|
19
|
+
project/port overrides and the independent app workflow.
|
|
20
|
+
|
|
21
|
+
Verification runs ESLint, the TypeScript type check (`npm run typecheck`,
|
|
22
|
+
strict, over `src`, `scripts`, `test` and `benchmarks`), syntax/JSON checks and
|
|
23
|
+
unit/real HTTP tests; keep all of it green. There is no build in the local
|
|
24
|
+
loop: `npm run dev` runs `src/cli.ts` directly. `npm run build` emits `dist/`,
|
|
25
|
+
the JavaScript the package and container run, plus its declarations; `dist` is
|
|
26
|
+
never committed. Package verification builds, installs an actual archive in a
|
|
27
|
+
temporary directory and checks the starter and a TypeScript consumer of the
|
|
28
|
+
shipped declarations. It needs npm registry access. Default runtime tests use only local
|
|
29
|
+
HTTP/fake services; no hosting account, DB or ngrok. Benchmarks are separate:
|
|
30
|
+
`npm run benchmark -- 10000`.
|
|
31
|
+
|
|
32
|
+
Keep changes consistent with the [implemented contract](docs/SPECIFICATION.md)
|
|
33
|
+
and [roadmap](ROADMAP.md). Add behavior/conformance tests for routing changes and
|
|
34
|
+
update docs when support changes. Do not claim a provider or OS is supported
|
|
35
|
+
without a passing test run. Preserve portable behavior and useful self-hosting.
|
|
36
|
+
|
|
37
|
+
Use synthetic data. Never commit secrets, customer URL collections or local
|
|
38
|
+
environment files. Treat all application function code as untrusted. Never import it into Node or
|
|
39
|
+
add an unsafe fallback. Capability grants must come from operator policy outside
|
|
40
|
+
the project. Extend adversarial tests with every new guest/host bridge. See the
|
|
41
|
+
[security model](docs/FUNCTION-SECURITY.md).
|
|
42
|
+
|
|
43
|
+
## Maintaining the starter
|
|
44
|
+
|
|
45
|
+
`starters/default` is the only initializer source. Keep its route YAML, functions
|
|
46
|
+
and request fixtures aligned with the public `urlcode-template` repository.
|
|
47
|
+
The public template adds its pinned runtime dependency, npm commands and CI;
|
|
48
|
+
CLI initialization uses the user's already installed runtime. Test both paths.
|
|
49
|
+
The richer asset demo lives in `examples/assets`, not a selectable starter.
|
|
50
|
+
Old starter-dynamic/starter-redirects branches are historical and no longer
|
|
51
|
+
maintained; do not use them in onboarding or publish further subtree updates.
|
|
52
|
+
|
|
53
|
+
## Keep authoring documentation executable
|
|
54
|
+
|
|
55
|
+
When changing YAML fields, update schema and semantics, run `npm run docs:reference`,
|
|
56
|
+
and add a runnable example/response fixture in `examples/cookbook` where appropriate.
|
|
57
|
+
`npm run verify` rejects a stale generated field reference. CI runs cookbook tests
|
|
58
|
+
and its expected-count audit on supported Node/OS combinations; package checks
|
|
59
|
+
verify the cookbook and AI authoring resources ship. Keep unsupported features
|
|
60
|
+
explicit in `docs/AI-AUTHORING.md`; never present future roadmap fields as valid YAML.
|
|
61
|
+
|
|
62
|
+
## Pull requests and review
|
|
63
|
+
|
|
64
|
+
Work on a branch and open a focused pull request. Explain the problem, resulting
|
|
65
|
+
behavior, validation and compatibility/security implications. Never include real
|
|
66
|
+
credentials or customer data. Use the PR template and keep unrelated changes out.
|
|
67
|
+
|
|
68
|
+
`main` requires a pull request, an up-to-date branch, the required Node/OS verification
|
|
69
|
+
jobs, container verification, CodeQL results and resolved conversations. High/critical
|
|
70
|
+
security findings and error-level CodeQL alerts block merging. Force pushes and branch
|
|
71
|
+
deletion are blocked; squash merging keeps a linear history. Administrators have
|
|
72
|
+
no configured ruleset bypass. Automation cannot approve pull requests.
|
|
73
|
+
|
|
74
|
+
The project currently has one maintainer, @jimhoyd. CODEOWNERS identifies the
|
|
75
|
+
responsible reviewer, but no second-person approval is required while there is
|
|
76
|
+
only one maintainer; this is not an independent review guarantee. Require an
|
|
77
|
+
independent approval when another trusted maintainer joins. Security-sensitive
|
|
78
|
+
changes warrant independent review before production use regardless of CI.
|
|
79
|
+
|
|
80
|
+
See [governance](GOVERNANCE.md) and the [code of conduct](CODE_OF_CONDUCT.md).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Jimmy Ho
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
URLCode
|
|
2
|
+
Copyright (c) the URLCode contributors
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
This product bundles User-Agent lists derived from third-party data. Each
|
|
7
|
+
upstream licence is reproduced verbatim under data/agents/LICENSES/, and the
|
|
8
|
+
pinned upstream revision is recorded in every data/agents/<list>.json file.
|
|
9
|
+
scripts/sync-agent-lists.js refreshes them.
|
|
10
|
+
|
|
11
|
+
ai.robots.txt (data/agents/ai-crawlers.json)
|
|
12
|
+
https://github.com/ai-robots-txt/ai.robots.txt
|
|
13
|
+
Copyright (c) 2024 ai.robots.txt
|
|
14
|
+
Licensed under the MIT License; see data/agents/LICENSES/ai-robots-txt.txt
|
|
15
|
+
|
|
16
|
+
crawler-user-agents (data/agents/crawlers.json, seo.json, monitoring.json)
|
|
17
|
+
https://github.com/monperrus/crawler-user-agents
|
|
18
|
+
Copyright (c) 2017 Martin Monperrus
|
|
19
|
+
Licensed under the MIT License; see data/agents/LICENSES/crawler-user-agents.txt
|
|
20
|
+
Only revisions dated after 2016-11-07 are used, when the project moved to MIT.
|
package/README.md
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# URLCode
|
|
2
|
+
|
|
3
|
+
**A portable runtime for programmable URL behavior.** Define an application's
|
|
4
|
+
public URL surface in YAML, add isolated JavaScript only where declarative
|
|
5
|
+
handlers are not enough, and run the same project locally or on your own
|
|
6
|
+
infrastructure. Your routes, source and data remain yours.
|
|
7
|
+
|
|
8
|
+
[](https://github.com/jimhoyd-com/urlcode/actions/workflows/ci.yml)
|
|
9
|
+
|
|
10
|
+
[Documentation](docs/README.md) · [Starter](https://github.com/jimhoyd-com/urlcode-template) · [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md)
|
|
11
|
+
|
|
12
|
+
URLCode is not a URL shortener. Short links are one supported route type beside
|
|
13
|
+
redirects, validated HTTP responses, isolated request functions, middleware,
|
|
14
|
+
pages, static assets and downloads. It is also not a general Node web framework:
|
|
15
|
+
the project format intentionally describes bounded behavior that a runtime can
|
|
16
|
+
validate, inspect and eventually carry across hosting providers.
|
|
17
|
+
|
|
18
|
+
See [project direction](docs/PROJECT-DIRECTION.md) for the product boundary,
|
|
19
|
+
the relationship to application projects and the license.
|
|
20
|
+
|
|
21
|
+
## Status
|
|
22
|
+
|
|
23
|
+
`0.2.0` is the current local/self-hosted release of the implemented
|
|
24
|
+
contract, following `0.1.0`, the first stable one. It includes redirects, parameters, JavaScript
|
|
25
|
+
functions, middleware, live short-link storage, pages, static assets, downloads, starters, tests and process/container packaging. See the
|
|
26
|
+
[implemented contract](docs/SPECIFICATION.md), [operations guide](docs/OPERATIONS.md)
|
|
27
|
+
and [roadmap](ROADMAP.md) for limits and unfinished work.
|
|
28
|
+
|
|
29
|
+
Live-link storage uses separate bounded reader/writer pools. It requires a Node
|
|
30
|
+
build containing a patched SQLite version — 3.51.3 or newer, 3.50.7, or 3.44.6 —
|
|
31
|
+
which some current releases on a supported Node line do not carry. Run
|
|
32
|
+
`urlcode doctor` and check `liveLinks` before relying on it; everything else
|
|
33
|
+
runs on any supported Node.
|
|
34
|
+
See [pool controls and scaling limits](docs/DYNAMIC-LINKS.md#separate-reader-and-writer-pools).
|
|
35
|
+
|
|
36
|
+
URLCode is free and open-source software licensed under the
|
|
37
|
+
[Apache License 2.0](LICENSE). Commercial use, modification, redistribution and
|
|
38
|
+
self-hosting are permitted under its terms.
|
|
39
|
+
|
|
40
|
+
## Documentation
|
|
41
|
+
|
|
42
|
+
Start with the [YAML guide and recipe book](docs/YAML-GUIDE.md),
|
|
43
|
+
[complete field reference](docs/YAML-REFERENCE.md), and
|
|
44
|
+
[runnable 25-route cookbook](examples/cookbook/README.md). For AI-assisted
|
|
45
|
+
authoring, use [the AI guide](docs/AI-AUTHORING.md) and [llms.txt](llms.txt).
|
|
46
|
+
Follow [organization and readability practices](docs/BEST-PRACTICES.md) as your
|
|
47
|
+
project grows. Operators should read [capacity/concurrency](docs/CAPACITY.md) and the
|
|
48
|
+
[DDoS and recovery playbook](docs/RESILIENCE.md). Embedding the runtime from
|
|
49
|
+
TypeScript is covered in [TypeScript](docs/TYPESCRIPT.md). [All documentation](docs/README.md).
|
|
50
|
+
|
|
51
|
+
## Start your own project
|
|
52
|
+
|
|
53
|
+
Use [urlcode-template](https://github.com/jimhoyd-com/urlcode-template) for a small
|
|
54
|
+
app with just a function route and a regular redirect. Clone it or use GitHub’s
|
|
55
|
+
**Use this template** button, then run `npm ci` and `npm run dev`. The runtime is
|
|
56
|
+
a pinned dependency; no separate checkout or global installation is needed.
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
git clone https://github.com/jimhoyd-com/urlcode-template.git my-links
|
|
60
|
+
cd my-links
|
|
61
|
+
npm ci
|
|
62
|
+
npm run dev
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Live stored-link routes require **`dynamicLinks: true`** in the entry `urlcode.yaml`;
|
|
66
|
+
the starter explicitly sets false. Ordinary functions and parameterized redirects
|
|
67
|
+
do not need it. [Live-link setup](docs/DYNAMIC-LINKS.md).
|
|
68
|
+
|
|
69
|
+
## Built with URLCode
|
|
70
|
+
|
|
71
|
+
[urlcode-shortener](https://github.com/jimhoyd-com/urlcode-shortener) is a
|
|
72
|
+
standalone, account-free demo built on URLCode's public runtime and storage APIs.
|
|
73
|
+
It combines short links that expire after one hour or less, QR downloads, and a
|
|
74
|
+
shadcn/ui + Tailwind frontend. URLCode handles the page/assets and stored-link
|
|
75
|
+
redirects; the application adds anonymous creation and its own limits.
|
|
76
|
+
|
|
77
|
+
Read its [build retrospective](https://github.com/jimhoyd-com/urlcode-shortener/blob/main/docs/BUILD-RETROSPECTIVE.md)
|
|
78
|
+
for what the runtime supplied, what the application still needed, and proposed
|
|
79
|
+
improvements. The demo's license, hosting and production validation remain open;
|
|
80
|
+
it does not change URLCode's Apache-2.0 license or guest isolation model.
|
|
81
|
+
|
|
82
|
+
[urlcode-docs](https://github.com/jimhoyd-com/urlcode-docs) demonstrates URLCode
|
|
83
|
+
hosting a static documentation site with shadcn/ui and Tailwind. It syncs this
|
|
84
|
+
repository’s Markdown and examples at a pinned revision, applies templates through
|
|
85
|
+
sandboxed middleware during the build, and serves the output through native
|
|
86
|
+
page/static/download routes. This repository remains the documentation source of
|
|
87
|
+
truth. See the [docs-site retrospective](https://github.com/jimhoyd-com/urlcode-docs/blob/main/docs/BUILD-RETROSPECTIVE.md)
|
|
88
|
+
for reuse, integration work and upstream improvements. Hosting and a public domain
|
|
89
|
+
are not yet selected; the original site-code license is pending.
|
|
90
|
+
|
|
91
|
+
## Start from YAML
|
|
92
|
+
|
|
93
|
+
Already wrote `urlcode.yaml`? Run `urlcode scaffold --project ./my-links --dry-run`,
|
|
94
|
+
then remove `--dry-run` to create missing modules, pages and directories. Existing
|
|
95
|
+
files are preserved; code placeholders return 501 until implemented.
|
|
96
|
+
[Scaffolding guide](docs/SCAFFOLDING.md).
|
|
97
|
+
|
|
98
|
+
## Try it
|
|
99
|
+
|
|
100
|
+
Requires Node.js 22.13+ and npm; CI targets Node 22, 24 and 26 on macOS, Linux and
|
|
101
|
+
Windows.
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
npm install --global urlcode # or: brew tap jimhoyd-com/urlcode && brew install urlcode
|
|
105
|
+
urlcode init my-urls && cd my-urls
|
|
106
|
+
urlcode dev
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
See [installation](docs/INSTALL.md) for the install script, the container image
|
|
110
|
+
and verifying a release's signed provenance. To work from a clone instead:
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
git clone https://github.com/jimhoyd-com/urlcode.git
|
|
114
|
+
cd urlcode
|
|
115
|
+
make dev
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`make dev` installs dependencies if needed and starts the included function/redirect demo.
|
|
119
|
+
No global install, account, database, Docker or configuration step is required.
|
|
120
|
+
A clone runs the TypeScript source directly (`node src/cli.ts`, which needs
|
|
121
|
+
Node 22.18+); the installed package runs the built `dist/cli.js`.
|
|
122
|
+
Without Make (including Windows), use:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
npm ci
|
|
126
|
+
npm run dev
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Open `http://127.0.0.1:3000/hello/Ada` to run your custom function,
|
|
130
|
+
`/go` for a regular redirect.
|
|
131
|
+
Edit `starters/default/routes/` or `functions/hello.mjs` under
|
|
132
|
+
that starter; valid changes reload automatically. Press Ctrl+C to stop.
|
|
133
|
+
In another terminal, run `make test-project` or `npm run test:project`.
|
|
134
|
+
|
|
135
|
+
To create your own independent project:
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
make init DEST=../my-links
|
|
139
|
+
make dev PROJECT=../my-links PORT=3001
|
|
140
|
+
# Without Make:
|
|
141
|
+
npm run init -- ../my-links
|
|
142
|
+
npm run dev -- --project ../my-links --port 3001
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Choose either command pair; initialization refuses to overwrite existing work.
|
|
146
|
+
[Starters](docs/STARTERS.md) are ordinary application files, independent of the
|
|
147
|
+
runtime checkout. Own them in your own Git repository. Global `npm link` remains
|
|
148
|
+
optional if you want the `urlcode` command everywhere. See
|
|
149
|
+
[local development](docs/LOCAL-DEVELOPMENT.md) for commands and troubleshooting.
|
|
150
|
+
|
|
151
|
+
## A URL that runs your function
|
|
152
|
+
|
|
153
|
+
A request to `/hello/Ada` runs your JavaScript and returns
|
|
154
|
+
`{"message":"Hello, Ada!"}`. Put this in `urlcode.yaml`:
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
version: "1"
|
|
158
|
+
routes:
|
|
159
|
+
/hello/{name}:
|
|
160
|
+
parameters:
|
|
161
|
+
- name: name
|
|
162
|
+
in: path
|
|
163
|
+
required: true
|
|
164
|
+
schema: {type: string, minLength: 1, maxLength: 80}
|
|
165
|
+
function:
|
|
166
|
+
source: functions/hello.mjs
|
|
167
|
+
args:
|
|
168
|
+
name: {from: path, name: name}
|
|
169
|
+
env:
|
|
170
|
+
GREETING: {value: Hello}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
And in `functions/hello.mjs`:
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
export default function hello(request, { args, env }) {
|
|
177
|
+
return Response.json({ message: `${env.GREETING}, ${args.name}!` });
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Your function chooses the response: JSON, text, HTML, or a redirect via
|
|
182
|
+
`Response.redirect("https://example.com", 302)`. The starter includes
|
|
183
|
+
this runnable example. Functions run in an isolated sandbox; see its supported
|
|
184
|
+
[API and security boundaries](docs/FUNCTION-SECURITY.md).
|
|
185
|
+
|
|
186
|
+
## Reusable middleware
|
|
187
|
+
|
|
188
|
+
Add an ordered `middleware` list alongside any route handler:
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
middleware:
|
|
192
|
+
- source: middleware/headers.mjs
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```js
|
|
196
|
+
export default async function headers(request, context, next) {
|
|
197
|
+
const response = await next();
|
|
198
|
+
response.headers.set('x-example-middleware', 'active');
|
|
199
|
+
return response;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Middleware can return a response early, share request-local `context.state`, or
|
|
204
|
+
wrap the handler with `await next()`. It runs in the same isolated sandbox and
|
|
205
|
+
under one deadline for the whole chain. The starter's function route includes
|
|
206
|
+
this example. See [middleware semantics and limits](docs/MIDDLEWARE.md).
|
|
207
|
+
|
|
208
|
+
## A URL that redirects
|
|
209
|
+
|
|
210
|
+
```yaml
|
|
211
|
+
version: "1"
|
|
212
|
+
routes:
|
|
213
|
+
/go:
|
|
214
|
+
redirect:
|
|
215
|
+
url: https://example.com
|
|
216
|
+
status: 302
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Ordinary redirects use an indexed lookup: no database, Lambda or per-route
|
|
220
|
+
user function. Configuration is compiled at startup, not parsed per request.
|
|
221
|
+
Literal paths win over parameterized routes; conflicting definitions fail validation.
|
|
222
|
+
|
|
223
|
+
Custom functions are ES modules using a documented text/JSON `Request`/`Response`
|
|
224
|
+
subset and validated context. See the
|
|
225
|
+
[starter](starters/default/urlcode.yaml) and [function](starters/default/functions/hello.mjs).
|
|
226
|
+
Functions are treated as untrusted and run inside a QuickJS/WebAssembly sandbox,
|
|
227
|
+
with a fresh heap per invocation. No Node APIs, filesystem, shell, network or
|
|
228
|
+
ambient environment is exposed. Independent worker deadlines bound execution.
|
|
229
|
+
External env/secret bindings require route-scoped operator grants pinned to the
|
|
230
|
+
project revision. See the [security model](docs/FUNCTION-SECURITY.md).
|
|
231
|
+
|
|
232
|
+
## Pages, files and downloads
|
|
233
|
+
|
|
234
|
+
Add these routes alongside your functions and redirects:
|
|
235
|
+
|
|
236
|
+
```yaml
|
|
237
|
+
/about:
|
|
238
|
+
page:
|
|
239
|
+
file: public/about.html
|
|
240
|
+
/assets/*:
|
|
241
|
+
static:
|
|
242
|
+
directory: public/assets
|
|
243
|
+
/download:
|
|
244
|
+
download:
|
|
245
|
+
file: public/guide.txt
|
|
246
|
+
filename: urlcode-guide.txt
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Create the referenced files first. MIME types are detected from file extensions;
|
|
250
|
+
unknown types use `application/octet-stream`. Downloads set attachment headers.
|
|
251
|
+
Optional `contentType` overrides detection. HEAD, ETags, conditional requests and
|
|
252
|
+
single byte ranges are supported. Files are served natively without executing a
|
|
253
|
+
function. See [asset configuration and safety limits](docs/ASSETS.md).
|
|
254
|
+
|
|
255
|
+
## Organize routes across files
|
|
256
|
+
|
|
257
|
+
Keep everything in `urlcode.yaml`, or use its `includes` list to load files from
|
|
258
|
+
folders you choose. The [public template](https://github.com/jimhoyd-com/urlcode-template)
|
|
259
|
+
demonstrates a function file and a redirect file in a nested folder. All commands
|
|
260
|
+
see one combined project. See [organization examples](docs/ORGANIZATION.md).
|
|
261
|
+
|
|
262
|
+
## Route matching and adding links
|
|
263
|
+
|
|
264
|
+
Routes support exact paths and non-greedy single-segment parameters such as
|
|
265
|
+
`/r/{code}`. Only static-file mounts support a trailing `/*`; regex routing is
|
|
266
|
+
not supported. `dev` swaps validated configuration snapshots when YAML changes;
|
|
267
|
+
`serve` requires restart/redeployment for YAML changes. Stored short links can
|
|
268
|
+
now be created/updated/deleted live without reloads through the optional
|
|
269
|
+
[dynamic-link handler and management API](docs/DYNAMIC-LINKS.md). See [matching, precedence and dynamic-link behavior](docs/ROUTING.md).
|
|
270
|
+
|
|
271
|
+
## Create short links without restarting
|
|
272
|
+
|
|
273
|
+
```yaml
|
|
274
|
+
/r/{code}:
|
|
275
|
+
parameters:
|
|
276
|
+
- name: code
|
|
277
|
+
in: path
|
|
278
|
+
required: true
|
|
279
|
+
schema: {type: string, minLength: 1, maxLength: 128}
|
|
280
|
+
link:
|
|
281
|
+
collection: links
|
|
282
|
+
code: {from: path, name: code}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Keep this route in YAML; store individual codes outside Git. Bind an optional
|
|
286
|
+
local SQLite store with `--link-store links=/absolute/links.sqlite`, then use
|
|
287
|
+
`urlcode links create` or the separate authenticated management API. Successful
|
|
288
|
+
record changes are visible without rewriting YAML or rebuilding the route table.
|
|
289
|
+
Ordinary YAML routes still need no database. See [setup, API and limitations](docs/DYNAMIC-LINKS.md).
|
|
290
|
+
|
|
291
|
+
## HTTP in YAML
|
|
292
|
+
|
|
293
|
+
Configure methods and validated path/query/header inputs, request body size and
|
|
294
|
+
media types, response headers, cookies, and declared text/JSON responses.
|
|
295
|
+
See the [HTTP configuration reference](docs/HTTP.md) for supported fields and
|
|
296
|
+
examples. Runtime framing and asset validators stay protected.
|
|
297
|
+
|
|
298
|
+
## Check your links before release
|
|
299
|
+
|
|
300
|
+
`urlcode routes` lists the configured routes. `urlcode audit --expect-routes 2`
|
|
301
|
+
checks the count, generates native response checks and reports missing route/method
|
|
302
|
+
coverage in your request fixtures. `urlcode benchmark --requests 1000 --concurrency 2`
|
|
303
|
+
measures your local project without following external redirects. Each command
|
|
304
|
+
accepts `--project`. See [readiness and release checks](docs/READINESS.md).
|
|
305
|
+
|
|
306
|
+
## Commands available
|
|
307
|
+
|
|
308
|
+
| Command | Purpose |
|
|
309
|
+
|---|---|
|
|
310
|
+
| `init <directory>` | Create an independent starter; refuse existing destinations |
|
|
311
|
+
| `add <url> --alias <code>` | Validate and atomically add a redirect; generate a code if omitted |
|
|
312
|
+
| `validate --local` | Validate config, references, bindings and function initialization; read `.env.local` |
|
|
313
|
+
| `dev` | Local server, watched reload and `.env.local` |
|
|
314
|
+
| `serve` | Fixed production process snapshot; environment injection, no dotenv loading |
|
|
315
|
+
| `test` | Local HTTP assertions from `tests/requests.json`; never follow redirects |
|
|
316
|
+
| `permissions` | Inspect requested bindings and project digest without executing code; grants nothing |
|
|
317
|
+
| `doctor` | Report runtime/platform details and implemented provider scope |
|
|
318
|
+
|
|
319
|
+
Use `--project <directory>` to select an app. Servers accept `--host`, `--port`
|
|
320
|
+
and `--origin` (public URL origin for functions). Bind defaults to `127.0.0.1`.
|
|
321
|
+
|
|
322
|
+
## Production direction
|
|
323
|
+
|
|
324
|
+
The free runtime is meant to be useful and production-capable for people who
|
|
325
|
+
operate it themselves. Current hardening includes strict YAML/schema checks,
|
|
326
|
+
request/response limits, worker deadlines, bounded function concurrency, safe
|
|
327
|
+
configuration replacement, graceful shutdown, health/readiness and structured
|
|
328
|
+
logs without request content. It still needs broader deployment/soak validation
|
|
329
|
+
and the remaining release features. Read [operations](docs/OPERATIONS.md) before
|
|
330
|
+
exposing a server. [Benchmark instructions and measurements](docs/PERFORMANCE.md)
|
|
331
|
+
are available; measurements are not capacity guarantees.
|
|
332
|
+
|
|
333
|
+
Git owns definitions and code. Secrets stay in ignored `.env.local` for development
|
|
334
|
+
or injected environment values for serving, accessible to functions only through
|
|
335
|
+
an explicit operator policy. Vercel, AWS Lambda and Cloudflare Workers each have a
|
|
336
|
+
target guide in [docs](docs/README.md); none has been deployed to its platform
|
|
337
|
+
yet. Provider secret-store integration, CSV tools, templates/signals,
|
|
338
|
+
Homebrew and richer monitoring are future work. Unsupported config fails rather
|
|
339
|
+
than silently losing behavior. There is no required admin UI or database.
|
|
340
|
+
|
|
341
|
+
See [contributing](CONTRIBUTING.md), [security](SECURITY.md), and the
|
|
342
|
+
[roadmap](ROADMAP.md).
|