From 6f8f6831f49b47bd181c68f194f1e818b502d4ae Mon Sep 17 00:00:00 2001 From: Mark Gibson Date: Thu, 18 Apr 2024 08:53:12 +0100 Subject: [PATCH] Migrate to separate @http packages --- .github/workflows/deploy.yml | 2 +- cache/index.html | 5 +- deno.json | 44 ++++-- deno.lock | 202 +++++++++++++++++++-------- dev.ts | 17 +++ handler.ts | 6 +- import_map_sw.json | 9 +- lib/content.ts | 2 +- lib/cron_route_mapper.ts | 2 +- lib/generate_cron_module.ts | 6 +- lib/handle_fragment.ts | 2 +- lib/handle_page.ts | 2 +- lib/handle_route_md.tsx | 4 +- lib/handle_route_static_dir.ts | 6 +- lib/render_html.tsx | 4 +- lib/route_mapper.ts | 2 +- main.ts | 2 +- routes.ts | 8 +- routes/_static/sw.js | 22 +-- routes/_static/sw_compat.js | 22 +-- routes/blog/_fs_based_routing.md | 14 +- routes/blog/links.md | 3 +- routes/calc/_components/Evaluate.tsx | 2 +- routes/ex/_components/Exchange.tsx | 2 +- routes/quiz/answer/:id/:answer.tsx | 2 +- routes/quiz/index.tsx | 2 +- routes/quote/index.tsx | 2 +- routes/quote/tv.ts | 2 +- routes/sse/feed.tsx | 2 +- routes/todo/:listId/:itemId.tsx | 8 +- routes/todo/:listId/index.tsx | 6 +- routes/todo/_lib/data.ts | 2 +- routes/todo/index.ts | 2 +- scripts/build.ts | 2 +- scripts/cache.ts | 6 +- scripts/dev.ts | 17 --- scripts/discover_routes.ts | 4 +- scripts/gen.ts | 6 +- service_worker/routes.ts | 4 +- 39 files changed, 274 insertions(+), 183 deletions(-) create mode 100644 dev.ts delete mode 100644 scripts/dev.ts diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ae8de99..5afbd0e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,4 +19,4 @@ jobs: with: project: jollytoad entrypoint: main.ts - exclude: scripts + exclude: scripts, dev.ts, import_map_sw.json, README.md diff --git a/cache/index.html b/cache/index.html index ad182ca..63afdac 100644 --- a/cache/index.html +++ b/cache/index.html @@ -23,13 +23,12 @@ service
  • htmx - used for many of the interactive demos
  • missing.css - css library
  • -
  • @http/fns - my HTTP server functions library (for +
  • HTTP Functions - my HTTP server functions library (for routing etc)
  • @http/jsx-stream - my JSX streaming serializer
  • remark - the markdown processor (although I use mdast and it's utilities directly)
  • esbuild - to build the service worker, as not -all browsers support ESM in service workers yet -(Deno module)
  • +all browsers support ESM in service workers yet
    \ No newline at end of file diff --git a/deno.json b/deno.json index 71bb983..71f245a 100644 --- a/deno.json +++ b/deno.json @@ -8,7 +8,7 @@ "cache": "deno run --allow-all scripts/cache.ts", "cache:clean": "rm -rf cache", "gen": "deno run --allow-net --allow-read --allow-write --allow-env scripts/gen.ts", - "start": "deno run --allow-net --allow-read --allow-env --env --allow-sys --allow-run --allow-write --allow-hrtime --watch scripts/dev.ts", + "start": "deno run --allow-net --allow-read --allow-env --env --allow-sys --allow-run --allow-write --allow-hrtime --watch dev.ts", "start:prod": "deno run --allow-net --allow-env main.ts", "mkcert": "mkcert -install -key-file localhost-key.pem -cert-file localhost-cert.pem localhost", "deploy": "deno run --allow-sys --allow-net --allow-read --allow-write --allow-env jsr:@deno/deployctl deploy", @@ -35,21 +35,29 @@ "imports": { "$store": "https://deno.land/x/storage_modules@v0.1.0/deno_kv.ts", "@cross/env": "jsr:@cross/env@^1.0.0", - "@http/fns": "jsr:@http/fns@^0.7.0", - "@http/fns/": "jsr:/@http/fns@^0.7.0/", + "@http/discovery/": "jsr:/@http/discovery@^0.9.0-beta.2/", + "@http/generate/": "jsr:/@http/generate@^0.9.0-beta.2/", + "@http/handler/": "jsr:/@http/handler@^0.9.0-beta.2/", + "@http/host-deno-deploy/": "jsr:/@http/host-deno-deploy@^0.9.0-beta.2/", + "@http/host-deno-local/": "jsr:/@http/host-deno-local@^0.9.0-beta.2/", + "@http/interceptor/": "jsr:/@http/interceptor@^0.9.0-beta.2/", "@http/jsx-stream": "jsr:@http/jsx-stream@^0.1.1", "@http/jsx-stream/": "jsr:/@http/jsx-stream@^0.1.1/", - "@std/async": "jsr:@std/async@^0.219.1", - "@std/async/": "jsr:/@std/async@^0.219.1/", - "@std/collections": "jsr:@std/collections@^0.219.1", - "@std/collections/": "jsr:/@std/collections@^0.219.1/", - "@std/fs": "jsr:@std/fs@^0.219.1", - "@std/fs/": "jsr:/@std/fs@^0.219.1/", - "@std/http": "jsr:@std/http@^0.219.1", - "@std/http/": "jsr:/@std/http@^0.219.1/", - "@std/path": "jsr:@std/path@^0.219.1", - "@std/path/": "jsr:/@std/path@^0.219.1/", - "@std/ulid": "jsr:@std/ulid@^0.219.1", + "@http/request/": "jsr:/@http/request@^0.9.0-beta.2/", + "@http/response/": "jsr:/@http/response@^0.9.0-beta.2/", + "@http/route/": "jsr:/@http/route@^0.9.0-beta.2/", + "@http/route-deno/": "jsr:/@http/route-deno@^0.9.0-beta.2/", + "@std/async": "jsr:@std/async@^0.222.1", + "@std/async/": "jsr:/@std/async@^0.222.1/", + "@std/collections": "jsr:@std/collections@^0.222.1", + "@std/collections/": "jsr:/@std/collections@^0.222.1/", + "@std/fs": "jsr:@std/fs@^0.222.1", + "@std/fs/": "jsr:/@std/fs@^0.222.1/", + "@std/http": "jsr:@std/http@^0.222.1", + "@std/http/": "jsr:/@std/http@^0.222.1/", + "@std/path": "jsr:@std/path@^0.222.1", + "@std/path/": "jsr:/@std/path@^0.222.1/", + "@std/ulid": "jsr:@std/ulid@^0.222.1", "esbuild": "npm:esbuild@0.20", "esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3", "hast-util-raw": "npm:hast-util-raw@9.0.2", @@ -63,7 +71,13 @@ }, "deploy": { "project": "jollytoad", - "exclude": [".env", "localhost-cert.pem", "localhost-key.pem", "scripts"], + "exclude": [ + ".env", + "localhost-cert.pem", + "localhost-key.pem", + "scripts", + "dev.ts" + ], "include": [], "entrypoint": "main.ts" } diff --git a/deno.lock b/deno.lock index 0c3e66e..b7604db 100644 --- a/deno.lock +++ b/deno.lock @@ -5,30 +5,43 @@ "jsr:@cross/deepmerge@^1.0.0": "jsr:@cross/deepmerge@1.0.0", "jsr:@cross/env@^1.0.0": "jsr:@cross/env@1.0.0", "jsr:@cross/runtime@^1.0.0": "jsr:@cross/runtime@1.0.0", - "jsr:@http/fns@^0.7.0": "jsr:@http/fns@0.7.0", - "jsr:@http/jsx-stream@0.1.1": "jsr:@http/jsx-stream@0.1.1", + "jsr:@http/discovery@0.9.0-beta.2": "jsr:@http/discovery@0.9.0-beta.2", + "jsr:@http/discovery@^0.9.0-beta.2": "jsr:@http/discovery@0.9.0-beta.2", + "jsr:@http/generate@^0.9.0-beta.2": "jsr:@http/generate@0.9.0-beta.2", + "jsr:@http/handler@0.9.0-beta.2": "jsr:@http/handler@0.9.0-beta.2", + "jsr:@http/handler@^0.9.0-beta.2": "jsr:@http/handler@0.9.0-beta.2", + "jsr:@http/host-deno-deploy@^0.9.0-beta.2": "jsr:@http/host-deno-deploy@0.9.0-beta.2", + "jsr:@http/host-deno-local@^0.9.0-beta.2": "jsr:@http/host-deno-local@0.9.0-beta.2", + "jsr:@http/interceptor@0.9.0-beta.2": "jsr:@http/interceptor@0.9.0-beta.2", + "jsr:@http/interceptor@^0.9.0-beta.2": "jsr:@http/interceptor@0.9.0-beta.2", "jsr:@http/jsx-stream@^0.1.1": "jsr:@http/jsx-stream@0.1.1", + "jsr:@http/request@^0.9.0-beta.2": "jsr:@http/request@0.9.0-beta.2", + "jsr:@http/response@0.9.0-beta.2": "jsr:@http/response@0.9.0-beta.2", + "jsr:@http/response@^0.9.0-beta.2": "jsr:@http/response@0.9.0-beta.2", + "jsr:@http/route-deno@^0.9.0-beta.2": "jsr:@http/route-deno@0.9.0-beta.2", + "jsr:@http/route@0.9.0-beta.2": "jsr:@http/route@0.9.0-beta.2", + "jsr:@http/route@^0.9.0-beta.2": "jsr:@http/route@0.9.0-beta.2", "jsr:@luca/esbuild-deno-loader@^0.10.3": "jsr:@luca/esbuild-deno-loader@0.10.3", "jsr:@std/assert@^0.213.1": "jsr:@std/assert@0.213.1", - "jsr:@std/assert@^0.219.1": "jsr:@std/assert@0.219.1", + "jsr:@std/assert@^0.222.1": "jsr:@std/assert@0.222.1", "jsr:@std/async@0.219": "jsr:@std/async@0.219.1", - "jsr:@std/async@^0.219.1": "jsr:@std/async@0.219.1", - "jsr:@std/cli@^0.219.1": "jsr:@std/cli@0.219.1", - "jsr:@std/collections@^0.219.1": "jsr:@std/collections@0.219.1", + "jsr:@std/async@^0.222.1": "jsr:@std/async@0.222.1", + "jsr:@std/cli@^0.222.1": "jsr:@std/cli@0.222.1", + "jsr:@std/collections@^0.222.1": "jsr:@std/collections@0.222.1", "jsr:@std/encoding@0.213": "jsr:@std/encoding@0.213.1", - "jsr:@std/encoding@^0.219.1": "jsr:@std/encoding@0.219.1", - "jsr:@std/fmt@^0.219.1": "jsr:@std/fmt@0.219.1", - "jsr:@std/fs@^0.219.1": "jsr:@std/fs@0.219.1", + "jsr:@std/encoding@^0.222.1": "jsr:@std/encoding@0.222.1", + "jsr:@std/fmt@^0.222.1": "jsr:@std/fmt@0.222.1", + "jsr:@std/fs@^0.222.1": "jsr:@std/fs@0.222.1", "jsr:@std/html@0.219": "jsr:@std/html@0.219.1", - "jsr:@std/http@^0.219.1": "jsr:@std/http@0.219.1", + "jsr:@std/http@^0.222.1": "jsr:@std/http@0.222.1", "jsr:@std/json@^0.213.1": "jsr:@std/json@0.213.1", "jsr:@std/jsonc@0.213": "jsr:@std/jsonc@0.213.1", - "jsr:@std/media-types@^0.219.1": "jsr:@std/media-types@0.219.1", - "jsr:@std/net@^0.219.1": "jsr:@std/net@0.219.1", + "jsr:@std/media-types@^0.222.1": "jsr:@std/media-types@0.222.1", + "jsr:@std/net@^0.222.1": "jsr:@std/net@0.222.1", "jsr:@std/path@0.213": "jsr:@std/path@0.213.1", - "jsr:@std/path@^0.219.1": "jsr:@std/path@0.219.1", - "jsr:@std/streams@^0.219.1": "jsr:@std/streams@0.219.1", - "jsr:@std/ulid@^0.219.1": "jsr:@std/ulid@0.219.1", + "jsr:@std/path@^0.222.1": "jsr:@std/path@0.222.1", + "jsr:@std/streams@^0.222.1": "jsr:@std/streams@0.222.1", + "jsr:@std/ulid@^0.222.1": "jsr:@std/ulid@0.222.1", "npm:esbuild@0.20": "npm:esbuild@0.20.2", "npm:hast-util-raw@9.0.2": "npm:hast-util-raw@9.0.2", "npm:hast-util-to-jsx-runtime@2.3.0": "npm:hast-util-to-jsx-runtime@2.3.0", @@ -53,13 +66,44 @@ "@cross/runtime@1.0.0": { "integrity": "dddecdf99182df13d50279d1e473f715e83d41961c5c22edd7bb0c4c3cf8a76a" }, - "@http/fns@0.7.0": { - "integrity": "a8d914e124d7b7308d8abca6e482d78b16b87ad976ca9aaad3aee38dd2edcb6e", + "@http/discovery@0.9.0-beta.2": { + "integrity": "382a1f45c55ba8d65676a372956b08593e2b56bee0ef8b63a3499bcdb0734149", "dependencies": [ - "jsr:@std/http@^0.219.1", - "jsr:@std/media-types@^0.219.1", - "jsr:@std/net@^0.219.1", - "jsr:@std/path@^0.219.1" + "jsr:@http/handler@0.9.0-beta.2", + "jsr:@http/route@0.9.0-beta.2", + "jsr:@std/path@^0.222.1" + ] + }, + "@http/generate@0.9.0-beta.2": { + "integrity": "6a4744aeadcd6f3a9a9474e94831f4c651b5a9a1df185a677fff85032a284c47", + "dependencies": [ + "jsr:@http/discovery@0.9.0-beta.2" + ] + }, + "@http/handler@0.9.0-beta.2": { + "integrity": "5b0d2fe447c26d778f029da53090023516bda67a432e444177533cd9d722711f" + }, + "@http/host-deno-deploy@0.9.0-beta.2": { + "integrity": "ff0e668e17a94332ebca9e01328e18486e85ab181a17839c21c434fdcf6b122c", + "dependencies": [ + "jsr:@http/handler@0.9.0-beta.2", + "jsr:@http/interceptor@0.9.0-beta.2", + "jsr:@http/route@0.9.0-beta.2" + ] + }, + "@http/host-deno-local@0.9.0-beta.2": { + "integrity": "007f5650b0214308c242eca92a91b865f98c6bb73a27d0856e58a4775e588de2", + "dependencies": [ + "jsr:@http/handler@0.9.0-beta.2", + "jsr:@http/interceptor@0.9.0-beta.2", + "jsr:@http/route@0.9.0-beta.2", + "jsr:@std/net@^0.222.1" + ] + }, + "@http/interceptor@0.9.0-beta.2": { + "integrity": "4b787b6c2ffabe88ad3f7091d2cb2300c894817d33bcdce39d53e8aeee926afa", + "dependencies": [ + "jsr:@http/handler@0.9.0-beta.2" ] }, "@http/jsx-stream@0.1.1": { @@ -69,6 +113,30 @@ "jsr:@std/html@0.219" ] }, + "@http/request@0.9.0-beta.2": { + "integrity": "1ec1d6bdadb76caf4a7b15934b57f0a5f4cfba1e13bdc35183b77a4e66d62330" + }, + "@http/response@0.9.0-beta.2": { + "integrity": "ecd4673a88432dc66a161ea5db69ce592ba675ca2f0e29c673540a7bb99d261b" + }, + "@http/route-deno@0.9.0-beta.2": { + "integrity": "1b185f8d61292b29baca4ddae18525091afc3eeb1aabf27796dd3f4d032f03e6", + "dependencies": [ + "jsr:@http/handler@0.9.0-beta.2", + "jsr:@http/route@0.9.0-beta.2", + "jsr:@std/http@^0.222.1" + ] + }, + "@http/route@0.9.0-beta.2": { + "integrity": "1edfb52f9dfca015ef7416016667a40d7d8745b356c42ce340f33769637b9870", + "dependencies": [ + "jsr:@http/handler@0.9.0-beta.2", + "jsr:@http/response@0.9.0-beta.2", + "jsr:@std/http@^0.222.1", + "jsr:@std/media-types@^0.222.1", + "jsr:@std/path@^0.222.1" + ] + }, "@luca/esbuild-deno-loader@0.10.3": { "integrity": "32fc93f7e7f78060234fd5929a740668aab1c742b808c6048b57f9aaea514921", "dependencies": [ @@ -80,46 +148,49 @@ "@std/assert@0.213.1": { "integrity": "24c28178b30c8e0782c18e8e94ea72b16282207569cdd10ffb9d1d26f2edebfe" }, - "@std/assert@0.219.1": { - "integrity": "e76c2a1799a78f0f4db7de04bdc9b908a7a4b821bb65eda0285885297d4fb8af" + "@std/assert@0.222.1": { + "integrity": "691637161ee584a9919d1f9950ddd1272feb8e0a19e83aa5b7563cedaf73d74c" }, "@std/async@0.219.1": { "integrity": "9401a6aa5a3292d639b71beceb19fb53c2148238c4d36b3ddf8c30980baa10e0" }, - "@std/cli@0.219.1": { - "integrity": "715a9926b58b89ef8a3c91e91633ac5f8176e0f02f6b3a16f0a67309e41a2911" + "@std/async@0.222.1": { + "integrity": "9584f4612f96e604a7e49dba3caf703c28d3921faa5be7147a78864a93831af6" + }, + "@std/cli@0.222.1": { + "integrity": "18b3c15840d68dc588db53613e0e9b196e30e33ea2a2906624c991c008421ffa" }, - "@std/collections@0.219.1": { - "integrity": "ed0adf354efaf90069a1e9af263b9941f6a370d16e8a98f2fc67d12ed75d825a" + "@std/collections@0.222.1": { + "integrity": "234099e08eead6a87e59f4f1abdcba35df5503cfb0e852e77a19f79359ed5760" }, "@std/encoding@0.213.1": { "integrity": "fcbb6928713dde941a18ca5db88ca1544d0755ec8fb20fe61e2dc8144b390c62" }, - "@std/encoding@0.219.1": { - "integrity": "77b30e481a596cfb2a8f2f38c3165e6035a4f76a7259bf89b6a622ceaf57d575" + "@std/encoding@0.222.1": { + "integrity": "fb6c1d38722feebc8d4a5efa3eb2039ecec0d50d053186240484d0c4a4ce1006" }, - "@std/fmt@0.219.1": { - "integrity": "2432152e927df249a207177aa048a6d9465956ea0047653ee6abd4f514db504f" + "@std/fmt@0.222.1": { + "integrity": "ec3382f9b0261c1ab1a5c804aa355d816515fa984cdd827ed32edfb187c0a722" }, - "@std/fs@0.219.1": { - "integrity": "c18daa9bede16463d040dcdde575fce13be4bb7807cb6211094abd0c723117a5", + "@std/fs@0.222.1": { + "integrity": "337613f33e6e5970dddb263c3a3e5b8e39c97810ad6fe326cb9f65146af2503b", "dependencies": [ - "jsr:@std/path@^0.219.1" + "jsr:@std/path@^0.222.1" ] }, "@std/html@0.219.1": { "integrity": "c4534f4ead24217b0347b92ddf034d782f1e4cf4b97b3c1f8185602ac71cadec" }, - "@std/http@0.219.1": { - "integrity": "444b9e212747a4a163f5d9f5e468d1159e3ff9915cbc60a5bac6043f4771649a", + "@std/http@0.222.1": { + "integrity": "a3c731ec6040927aa37d8378b9e6b467e2e3068c1f97838a6e79ee3bdc103521", "dependencies": [ - "jsr:@std/assert@^0.219.1", - "jsr:@std/cli@^0.219.1", - "jsr:@std/encoding@^0.219.1", - "jsr:@std/fmt@^0.219.1", - "jsr:@std/media-types@^0.219.1", - "jsr:@std/path@^0.219.1", - "jsr:@std/streams@^0.219.1" + "jsr:@std/assert@^0.222.1", + "jsr:@std/cli@^0.222.1", + "jsr:@std/encoding@^0.222.1", + "jsr:@std/fmt@^0.222.1", + "jsr:@std/media-types@^0.222.1", + "jsr:@std/path@^0.222.1", + "jsr:@std/streams@^0.222.1" ] }, "@std/json@0.213.1": { @@ -132,11 +203,11 @@ "jsr:@std/json@^0.213.1" ] }, - "@std/media-types@0.219.1": { - "integrity": "557c8d4fd82aa6df51bca18d14e08e8df7134816c8defb61c90ac48bf71ad7c4" + "@std/media-types@0.222.1": { + "integrity": "147cbd7f29fb4480625ccdad679637f945437f455534049eb7c95977b973a137" }, - "@std/net@0.219.1": { - "integrity": "4a07acc9eee6c83a2433587ee5b2bdac3410e418012292af8ac3097e7878cef9" + "@std/net@0.222.1": { + "integrity": "4b6936c2b7c1c0838ee9f0a3633d64a10e8dc0974cf9bc65fbb178b3921426c0" }, "@std/path@0.213.1": { "integrity": "f187bf278a172752e02fcbacf6bd78a335ed320d080a7ed3a5a59c3e88abc673", @@ -144,17 +215,17 @@ "jsr:@std/assert@^0.213.1" ] }, - "@std/path@0.219.1": { - "integrity": "e5c0ffef3a8ef2b48e9e3d88a1489320e8fb2cc7be767b17c91a1424ffb4c8ed", + "@std/path@0.222.1": { + "integrity": "aad3e9463ca53b0adb25b4d5beb330025674aaa3278da24c1c261d9289a9e48b", "dependencies": [ - "jsr:@std/assert@^0.219.1" + "jsr:@std/assert@^0.222.1" ] }, - "@std/streams@0.219.1": { - "integrity": "6f5dac5773a4fafdbe7ee612d0a0d5a2cbe465b9c9e2c85d371877dc8a52d1d3" + "@std/streams@0.222.1": { + "integrity": "0bb4220c1dc5106e45a309179f76df95c786c9fff814d195d5ee2160931bfc7c" }, - "@std/ulid@0.219.1": { - "integrity": "fef62db89887414936ac962b1862db12c969d20da35679a9c64876cd241bd5c4" + "@std/ulid@0.222.1": { + "integrity": "6366e88f26410e703f87d5a458742add41440f1f5b40e9a440253f0fd52da784" } }, "npm": { @@ -1177,15 +1248,24 @@ "workspace": { "dependencies": [ "jsr:@cross/env@^1.0.0", - "jsr:@http/fns@^0.7.0", + "jsr:@http/discovery@^0.9.0-beta.2", + "jsr:@http/generate@^0.9.0-beta.2", + "jsr:@http/handler@^0.9.0-beta.2", + "jsr:@http/host-deno-deploy@^0.9.0-beta.2", + "jsr:@http/host-deno-local@^0.9.0-beta.2", + "jsr:@http/interceptor@^0.9.0-beta.2", "jsr:@http/jsx-stream@^0.1.1", + "jsr:@http/request@^0.9.0-beta.2", + "jsr:@http/response@^0.9.0-beta.2", + "jsr:@http/route-deno@^0.9.0-beta.2", + "jsr:@http/route@^0.9.0-beta.2", "jsr:@luca/esbuild-deno-loader@^0.10.3", - "jsr:@std/async@^0.219.1", - "jsr:@std/collections@^0.219.1", - "jsr:@std/fs@^0.219.1", - "jsr:@std/http@^0.219.1", - "jsr:@std/path@^0.219.1", - "jsr:@std/ulid@^0.219.1", + "jsr:@std/async@^0.222.1", + "jsr:@std/collections@^0.222.1", + "jsr:@std/fs@^0.222.1", + "jsr:@std/http@^0.222.1", + "jsr:@std/path@^0.222.1", + "jsr:@std/ulid@^0.222.1", "npm:esbuild@0.20", "npm:hast-util-raw@9.0.2", "npm:hast-util-to-jsx-runtime@2.3.0", diff --git a/dev.ts b/dev.ts new file mode 100644 index 0000000..7d27af3 --- /dev/null +++ b/dev.ts @@ -0,0 +1,17 @@ +import handler from "./handler.ts"; +import { buildServiceWorker } from "./scripts/build.ts"; +import { generateCron, generateRoutes } from "./scripts/gen.ts"; +import init from "@http/host-deno-local/init"; +import initCron from "./cron.ts"; +import generateQuote from "./routes/quote/_cron/generate_quote.ts"; + +await generateRoutes(); +await generateCron(); + +await buildServiceWorker(); + +await generateQuote(); + +await initCron(); + +await Deno.serve(await init(handler)).finished; diff --git a/handler.ts b/handler.ts index c115688..bb0bafe 100644 --- a/handler.ts +++ b/handler.ts @@ -1,6 +1,6 @@ -import { handle } from "@http/fns/handle"; -import { staticRoute } from "@http/fns/static_route"; -import { interceptResponse, skip } from "@http/fns/intercept"; +import { handle } from "@http/route/handle"; +import { staticRoute } from "@http/route-deno/static-route"; +import { interceptResponse, skip } from "@http/interceptor/intercept"; import routes from "./routes.ts"; export default handle([ diff --git a/import_map_sw.json b/import_map_sw.json index 273c61c..08059eb 100644 --- a/import_map_sw.json +++ b/import_map_sw.json @@ -1,9 +1,10 @@ { "imports": { - "@http/fns": "jsr:@http/fns@^0.7.0", - "@http/fns/": "jsr:/@http/fns@^0.7.0/", - "@http/jsx-stream": "jsr:@http/jsx-stream@0.1.1", - "@http/jsx-stream/": "jsr:/@http/jsx-stream@0.1.1/", + "@http/jsx-stream": "jsr:@http/jsx-stream@^0.1.1", + "@http/jsx-stream/": "jsr:/@http/jsx-stream@^0.1.1/", + "@http/request/": "jsr:/@http/request@^0.9.0-beta.2/", + "@http/response/": "jsr:/@http/response@^0.9.0-beta.2/", + "@http/route/": "jsr:/@http/route@^0.9.0-beta.2/", "https://jsr.io/@http/jsx-stream/0.1.1/serialize.ts": "https://jsr.io/@http/jsx-stream/0.1.1/serialize_sw.ts", "urlpattern-polyfill": "npm:urlpattern-polyfill@10.0.0" } diff --git a/lib/content.ts b/lib/content.ts index f751670..283fc3d 100644 --- a/lib/content.ts +++ b/lib/content.ts @@ -1,4 +1,4 @@ -import { notFound } from "@http/fns/response/not_found"; +import { notFound } from "@http/response/not-found"; export async function fetchContent( name: string, diff --git a/lib/cron_route_mapper.ts b/lib/cron_route_mapper.ts index 6301af7..2af9827 100644 --- a/lib/cron_route_mapper.ts +++ b/lib/cron_route_mapper.ts @@ -1,7 +1,7 @@ import type { DiscoveredPath, DiscoveredRoute, -} from "@http/fns/discover_routes"; +} from "@http/discovery/discover-routes"; export default function cronRouteMapper( { parentPath, name, ext, pattern, module }: DiscoveredPath, diff --git a/lib/generate_cron_module.ts b/lib/generate_cron_module.ts index 52989f9..85a1a08 100644 --- a/lib/generate_cron_module.ts +++ b/lib/generate_cron_module.ts @@ -1,12 +1,12 @@ import { discoverRoutes, type DiscoverRoutesOptions, -} from "@http/fns/discover_routes"; +} from "@http/discovery/discover-routes"; import { dirname } from "@std/path/posix/dirname"; import { relative } from "@std/path/posix/relative"; -import { fromFileUrl } from "@std/path/posix/from_file_url"; +import { fromFileUrl } from "@std/path/posix/from-file-url"; import cronRouteMapper from "./cron_route_mapper.ts"; -import { asSerializablePattern } from "@http/fns/as_serializable_pattern"; +import { asSerializablePattern } from "@http/discovery/as-serializable-pattern"; export interface GenerateCronOptions extends Omit< diff --git a/lib/handle_fragment.ts b/lib/handle_fragment.ts index cdc7228..71c7aed 100644 --- a/lib/handle_fragment.ts +++ b/lib/handle_fragment.ts @@ -1,4 +1,4 @@ -import { byMethod } from "@http/fns/by_method"; +import { byMethod } from "@http/route/by-method"; import { FRAGMENT_RENDER_OPTIONS } from "../config_fragment.ts"; import type { ComponentType } from "@http/jsx-stream/types"; import type { RouteProps } from "./types.ts"; diff --git a/lib/handle_page.ts b/lib/handle_page.ts index 7e46a00..1fb51c6 100644 --- a/lib/handle_page.ts +++ b/lib/handle_page.ts @@ -1,4 +1,4 @@ -import { byMethod } from "@http/fns/by_method"; +import { byMethod } from "@http/route/by-method"; import type { ComponentType } from "@http/jsx-stream/types"; import type { RouteProps } from "./types.ts"; import { PAGE_RENDER_OPTIONS } from "../config_page.ts"; diff --git a/lib/handle_route_md.tsx b/lib/handle_route_md.tsx index 76a7cb3..10d43c1 100644 --- a/lib/handle_route_md.tsx +++ b/lib/handle_route_md.tsx @@ -1,8 +1,8 @@ -import { byMethod } from "@http/fns/by_method"; +import { byMethod } from "@http/route/by-method"; import { renderPage } from "./handle_page.ts"; import { Page } from "../components/Page.tsx"; import { Markdown } from "../components/Markdown.tsx"; -import { byMediaType } from "@http/fns/by_media_type"; +import { byMediaType } from "@http/route/by-media-type"; import { fetchContent } from "../lib/content.ts"; export default byMethod({ diff --git a/lib/handle_route_static_dir.ts b/lib/handle_route_static_dir.ts index 0a0ab5d..43169cb 100644 --- a/lib/handle_route_static_dir.ts +++ b/lib/handle_route_static_dir.ts @@ -1,6 +1,6 @@ -import { byMethod } from "@http/fns/by_method"; -import { serveDir } from "@std/http/file_server"; -import { fromFileUrl } from "@std/path/from_file_url"; +import { byMethod } from "@http/route/by-method"; +import { serveDir } from "@std/http/file-server"; +import { fromFileUrl } from "@std/path/from-file-url"; export default byMethod({ GET(req, match: URLPatternResult) { diff --git a/lib/render_html.tsx b/lib/render_html.tsx index e82e9a1..fc93644 100644 --- a/lib/render_html.tsx +++ b/lib/render_html.tsx @@ -1,5 +1,5 @@ -import { html } from "@http/fns/response/html"; -import { prependDocType } from "@http/fns/response/prepend_doctype"; +import { html } from "@http/response/html"; +import { prependDocType } from "@http/response/prepend-doctype"; import { type ComponentType, renderBody, diff --git a/lib/route_mapper.ts b/lib/route_mapper.ts index a281f3e..f61f405 100644 --- a/lib/route_mapper.ts +++ b/lib/route_mapper.ts @@ -1,7 +1,7 @@ import type { DiscoveredPath, DiscoveredRoute, -} from "@http/fns/discover_routes"; +} from "@http/discovery/discover-routes"; export default function routeMapper( { parentPath, name, ext, pattern, module }: DiscoveredPath, diff --git a/main.ts b/main.ts index c75cf73..5402886 100644 --- a/main.ts +++ b/main.ts @@ -1,5 +1,5 @@ import handler from "./handler.ts"; -import init from "@http/fns/hosting/init_deploy"; +import init from "@http/host-deno-deploy/init"; import initCron from "./cron.ts"; await initCron(); diff --git a/routes.ts b/routes.ts index 663992b..c5a1601 100644 --- a/routes.ts +++ b/routes.ts @@ -1,9 +1,9 @@ // IMPORTANT: This file has been automatically generated, DO NOT edit by hand. -import { byMethod } from "@http/fns/by_method"; -import { lazy } from "@http/fns/lazy"; -import { byPattern } from "@http/fns/by_pattern"; -import { cascade } from "@http/fns/cascade"; +import { byMethod } from "@http/route/by-method"; +import { lazy } from "@http/handler/lazy"; +import { byPattern } from "@http/route/by-pattern"; +import { cascade } from "@http/route/cascade"; export default cascade( byPattern("/todo/:listId/:itemId", lazy(async () => byMethod(await import("./routes/todo/:listId/:itemId.tsx")))), diff --git a/routes/_static/sw.js b/routes/_static/sw.js index 075eda5..2617f82 100644 --- a/routes/_static/sw.js +++ b/routes/_static/sw.js @@ -1,5 +1,5 @@ (() => { - // https://jsr.io/@http/fns/0.7.0/lib/as_url_pattern.ts + // https://jsr.io/@http/route/0.9.0-beta.2/as_url_pattern.ts function asURLPattern(pattern) { return typeof pattern === "string" ? new URLPattern({ pathname: pattern }) : pattern instanceof URLPattern ? pattern : new URLPattern(pattern); } @@ -7,7 +7,7 @@ return Array.isArray(pattern) ? pattern.map(asURLPattern) : [asURLPattern(pattern)]; } - // https://jsr.io/@http/fns/0.7.0/lib/by_pattern.ts + // https://jsr.io/@http/route/0.9.0-beta.2/by_pattern.ts function byPattern(pattern, handler) { const patterns = asURLPatterns(pattern); return async (req, ...args) => { @@ -24,7 +24,7 @@ }; } - // https://jsr.io/@http/fns/0.7.0/lib/cascade.ts + // https://jsr.io/@http/route/0.9.0-beta.2/cascade.ts function cascade(...handlers) { return async (req, ...args) => { for (const handler of handlers) { @@ -37,7 +37,7 @@ }; } - // https://jsr.io/@http/fns/0.7.0/lib/response/plain_error.ts + // https://jsr.io/@http/response/0.9.0-beta.2/plain_error.ts function plainError(status, statusText, message) { return new Response(message ?? statusText, { status, @@ -48,12 +48,12 @@ }); } - // https://jsr.io/@http/fns/0.7.0/lib/response/method_not_allowed.ts + // https://jsr.io/@http/response/0.9.0-beta.2/method_not_allowed.ts function methodNotAllowed(message) { return plainError(405, "Method Not Allowed", message); } - // https://jsr.io/@http/fns/0.7.0/lib/response/no_content.ts + // https://jsr.io/@http/response/0.9.0-beta.2/no_content.ts function noContent(headers) { return new Response(null, { status: 204, @@ -62,7 +62,7 @@ }); } - // https://jsr.io/@http/fns/0.7.0/lib/response/replace_body.ts + // https://jsr.io/@http/response/0.9.0-beta.2/replace_body.ts function replaceBody(res, body) { return res.body === body ? res : new Response(body, { status: res.status, @@ -71,7 +71,7 @@ }); } - // https://jsr.io/@http/fns/0.7.0/lib/by_method.ts + // https://jsr.io/@http/route/0.9.0-beta.2/by_method.ts function byMethod(handlers, fallback = () => methodNotAllowed()) { const defaultHandlers = { OPTIONS: optionsHandler(handlers) @@ -109,7 +109,7 @@ deferredTimeout: false }; - // https://jsr.io/@http/fns/0.7.0/lib/response/html.ts + // https://jsr.io/@http/response/0.9.0-beta.2/html.ts function html(body, headersInit) { const headers = new Headers(headersInit); headers.set("Content-Type", "text/html"); @@ -120,7 +120,7 @@ }); } - // https://jsr.io/@http/fns/0.7.0/lib/response/prepend_doctype.ts + // https://jsr.io/@http/response/0.9.0-beta.2/prepend_doctype.ts var DOCTYPE = "\n"; var ENCODED_DOCTYPE = new TextEncoder().encode(DOCTYPE); function prependDocType(bodyInit) { @@ -594,7 +594,7 @@ return evalRPN(toRPN(tokenize(input))); } - // https://jsr.io/@http/fns/0.7.0/lib/request/search_values.ts + // https://jsr.io/@http/request/0.9.0-beta.2/search_values.ts function getSearchValues(input) { const searchParams = input instanceof Request ? new URL(input.url).searchParams : input instanceof URL ? input.searchParams : input instanceof URLSearchParams ? input : input && "search" in input && "input" in input.search ? new URLSearchParams(input.search.input) : void 0; return (param, separator) => searchParams ? separator ? searchParams.getAll(param).join(separator).split(separator).filter( diff --git a/routes/_static/sw_compat.js b/routes/_static/sw_compat.js index 854413e..1d43948 100644 --- a/routes/_static/sw_compat.js +++ b/routes/_static/sw_compat.js @@ -788,7 +788,7 @@ globalThis.URLPattern = me; } - // https://jsr.io/@http/fns/0.7.0/lib/as_url_pattern.ts + // https://jsr.io/@http/route/0.9.0-beta.2/as_url_pattern.ts function asURLPattern(pattern) { return typeof pattern === "string" ? new URLPattern({ pathname: pattern }) : pattern instanceof URLPattern ? pattern : new URLPattern(pattern); } @@ -796,7 +796,7 @@ return Array.isArray(pattern) ? pattern.map(asURLPattern) : [asURLPattern(pattern)]; } - // https://jsr.io/@http/fns/0.7.0/lib/by_pattern.ts + // https://jsr.io/@http/route/0.9.0-beta.2/by_pattern.ts function byPattern(pattern, handler) { const patterns = asURLPatterns(pattern); return async (req, ...args) => { @@ -813,7 +813,7 @@ }; } - // https://jsr.io/@http/fns/0.7.0/lib/cascade.ts + // https://jsr.io/@http/route/0.9.0-beta.2/cascade.ts function cascade(...handlers) { return async (req, ...args) => { for (const handler of handlers) { @@ -826,7 +826,7 @@ }; } - // https://jsr.io/@http/fns/0.7.0/lib/response/plain_error.ts + // https://jsr.io/@http/response/0.9.0-beta.2/plain_error.ts function plainError(status, statusText, message) { return new Response(message ?? statusText, { status, @@ -837,12 +837,12 @@ }); } - // https://jsr.io/@http/fns/0.7.0/lib/response/method_not_allowed.ts + // https://jsr.io/@http/response/0.9.0-beta.2/method_not_allowed.ts function methodNotAllowed(message) { return plainError(405, "Method Not Allowed", message); } - // https://jsr.io/@http/fns/0.7.0/lib/response/no_content.ts + // https://jsr.io/@http/response/0.9.0-beta.2/no_content.ts function noContent(headers) { return new Response(null, { status: 204, @@ -851,7 +851,7 @@ }); } - // https://jsr.io/@http/fns/0.7.0/lib/response/replace_body.ts + // https://jsr.io/@http/response/0.9.0-beta.2/replace_body.ts function replaceBody(res, body) { return res.body === body ? res : new Response(body, { status: res.status, @@ -860,7 +860,7 @@ }); } - // https://jsr.io/@http/fns/0.7.0/lib/by_method.ts + // https://jsr.io/@http/route/0.9.0-beta.2/by_method.ts function byMethod(handlers, fallback = () => methodNotAllowed()) { const defaultHandlers = { OPTIONS: optionsHandler(handlers) @@ -898,7 +898,7 @@ deferredTimeout: false }; - // https://jsr.io/@http/fns/0.7.0/lib/response/html.ts + // https://jsr.io/@http/response/0.9.0-beta.2/html.ts function html(body, headersInit) { const headers = new Headers(headersInit); headers.set("Content-Type", "text/html"); @@ -909,7 +909,7 @@ }); } - // https://jsr.io/@http/fns/0.7.0/lib/response/prepend_doctype.ts + // https://jsr.io/@http/response/0.9.0-beta.2/prepend_doctype.ts var DOCTYPE = "\n"; var ENCODED_DOCTYPE = new TextEncoder().encode(DOCTYPE); function prependDocType(bodyInit) { @@ -1383,7 +1383,7 @@ return evalRPN(toRPN(tokenize(input))); } - // https://jsr.io/@http/fns/0.7.0/lib/request/search_values.ts + // https://jsr.io/@http/request/0.9.0-beta.2/search_values.ts function getSearchValues(input) { const searchParams = input instanceof Request ? new URL(input.url).searchParams : input instanceof URL ? input.searchParams : input instanceof URLSearchParams ? input : input && "search" in input && "input" in input.search ? new URLSearchParams(input.search.input) : void 0; return (param, separator) => searchParams ? separator ? searchParams.getAll(param).join(separator).split(separator).filter( diff --git a/routes/blog/_fs_based_routing.md b/routes/blog/_fs_based_routing.md index e60e970..140a60e 100644 --- a/routes/blog/_fs_based_routing.md +++ b/routes/blog/_fs_based_routing.md @@ -19,8 +19,8 @@ module with code using my [http_fns], so given the files: I'd get a module something like this: ```ts -import { byPattern } from "@http/fns/by_pattern"; -import { cascade } from "@http/fns/cascade"; +import { byPattern } from "@http/route/by-pattern"; +import { cascade } from "@http/route/cascade"; import route_1 from "./routes/quiz.tsx"; import route_2 from "./routes/answer/:id/:answer.tsx"; @@ -34,7 +34,7 @@ Which I could then import and combine in a server: ```ts import routes from "./routes.ts"; -import { withFallback } from "@http/fns/with_fallback"; +import { withFallback } from "@http/route/with-fallback"; Deno.serve(withFallback(routes)); ``` @@ -60,7 +60,7 @@ First I'll describe the more generic function... `discoverRoutes(options): Promise` ```ts -import { discoverRoutes } from "@http/fns/discover_routes"; +import { discoverRoutes } from "@http/discovery/discover-routes"; await discoverRoutes({ fileRouteUrl: import.meta.resolve("./routes"), @@ -83,8 +83,8 @@ If you want to customize the path format, to support Fresh style naming for example, you can pass a `PathMapper` function as an option. ```ts -import { discoverRoutes } from "@http/fns/discover_routes"; -import freshPathMapper from "@http/fns/fresh/path_mapper"; +import { discoverRoutes } from "@http/discovery/discover-routes"; +import freshPathMapper from "@http/discovery/fresh-path-mapper"; await discoverRoutes({ fileRootUrl: import.meta.resolve("../routes"), @@ -104,7 +104,7 @@ For example: `/routes/answer/:id/:answer.tsx`, this is an actual route on my home site, which is part of my Quiz example. ```ts -import { discoverRoutes } from "@http/fns/discover_routes"; +import { discoverRoutes } from "@http/discovery/discover-routes"; const routes = await discoverRoutes(); ``` diff --git a/routes/blog/links.md b/routes/blog/links.md index bab1f30..a4ddb9b 100644 --- a/routes/blog/links.md +++ b/routes/blog/links.md @@ -9,7 +9,7 @@ This site is powered by... service - [htmx](https://htmx.org) - used for many of the interactive demos - [missing.css](https://missing.style) - css library -- [@http/fns](https://jsr.io/@http/fns) - my HTTP server functions library (for +- [HTTP Functions](https://jsr.io/@http) - my HTTP server functions library (for routing etc) - [@http/jsx-stream](https://jsr.io/@http/jsx-stream) - my JSX streaming serializer @@ -17,4 +17,3 @@ This site is powered by... [mdast](https://github.com/syntax-tree/mdast) and it's utilities directly) - [esbuild](https://esbuild.github.io/) - to build the service worker, as not all browsers support ESM in service workers yet - ([Deno module](https://deno.land/x/esbuild)) diff --git a/routes/calc/_components/Evaluate.tsx b/routes/calc/_components/Evaluate.tsx index 3987ca9..7738882 100644 --- a/routes/calc/_components/Evaluate.tsx +++ b/routes/calc/_components/Evaluate.tsx @@ -1,5 +1,5 @@ import { evaluate } from "../_lib/evaluate.js"; -import { getSearchValues } from "@http/fns/request/search_values"; +import { getSearchValues } from "@http/request/search-values"; interface Props { expr: string; diff --git a/routes/ex/_components/Exchange.tsx b/routes/ex/_components/Exchange.tsx index 8b19bf9..8718f7c 100644 --- a/routes/ex/_components/Exchange.tsx +++ b/routes/ex/_components/Exchange.tsx @@ -1,4 +1,4 @@ -import { getSearchValues } from "@http/fns/request/search_values"; +import { getSearchValues } from "@http/request/search-values"; interface Props { id: string; diff --git a/routes/quiz/answer/:id/:answer.tsx b/routes/quiz/answer/:id/:answer.tsx index 4f9c7c7..aadf872 100644 --- a/routes/quiz/answer/:id/:answer.tsx +++ b/routes/quiz/answer/:id/:answer.tsx @@ -1,6 +1,6 @@ import { handleFragment } from "../../../../lib/handle_fragment.ts"; import { QuizAnswer } from "../../_components/QuizAnswer.tsx"; -import { notFound } from "@http/fns/response/not_found"; +import { notFound } from "@http/response/not-found"; import { getQuizSession, updateQuizScore } from "../../_lib/session.ts"; import { QuizScore } from "../../_components/QuizScore.tsx"; import type { TextChoiceQuestion } from "../../_trivia_api_types.ts"; diff --git a/routes/quiz/index.tsx b/routes/quiz/index.tsx index e526146..df76161 100644 --- a/routes/quiz/index.tsx +++ b/routes/quiz/index.tsx @@ -1,7 +1,7 @@ import { Page } from "../../components/Page.tsx"; import { Quiz } from "./_components/Quiz.tsx"; import { renderPage } from "../../lib/handle_page.ts"; -import { byMethod } from "@http/fns/by_method"; +import { byMethod } from "@http/route/by-method"; import { getQuizSession } from "../../routes/quiz/_lib/session.ts"; export default byMethod({ diff --git a/routes/quote/index.tsx b/routes/quote/index.tsx index bd1ab66..74b8e3c 100644 --- a/routes/quote/index.tsx +++ b/routes/quote/index.tsx @@ -1,6 +1,6 @@ import { Page } from "../../components/Page.tsx"; import { renderPage } from "../../lib/handle_page.ts"; -import { byMethod } from "@http/fns/by_method"; +import { byMethod } from "@http/route/by-method"; import { Quote } from "./_components/Quote.tsx"; import { getQuoteConfig } from "./_lib/quote_config.ts"; import { Src } from "../../components/Src.tsx"; diff --git a/routes/quote/tv.ts b/routes/quote/tv.ts index 27b2de6..efe4294 100644 --- a/routes/quote/tv.ts +++ b/routes/quote/tv.ts @@ -1,4 +1,4 @@ -import { byMethod } from "@http/fns/by_method"; +import { byMethod } from "@http/route/by-method"; import { renderHTML } from "../../lib/render_html.tsx"; import { QuoteTvPage } from "./_components/QuoteTvPage.tsx"; import { getQuoteConfig } from "./_lib/quote_config.ts"; diff --git a/routes/sse/feed.tsx b/routes/sse/feed.tsx index 29085d0..4f8b332 100644 --- a/routes/sse/feed.tsx +++ b/routes/sse/feed.tsx @@ -1,5 +1,5 @@ import { delay } from "@std/async/delay"; -import { ok } from "@http/fns/response/ok"; +import { ok } from "@http/response/ok"; import { renderString } from "@http/jsx-stream"; import type { JSX } from "@http/jsx-stream/jsx-runtime"; diff --git a/routes/todo/:listId/:itemId.tsx b/routes/todo/:listId/:itemId.tsx index 41f66f1..22f7a22 100644 --- a/routes/todo/:listId/:itemId.tsx +++ b/routes/todo/:listId/:itemId.tsx @@ -2,10 +2,10 @@ import { deleteItem, writeItem } from "../_lib/data.ts"; import type { TodoListItem } from "../_lib/types.ts"; import { TodoItemView } from "../_components/TodoItemView.tsx"; import { FRAGMENT_RENDER_OPTIONS } from "../../../config_fragment.ts"; -import { badRequest } from "@http/fns/response/bad_request"; -import { seeOther } from "@http/fns/response/see_other"; -import { ok } from "@http/fns/response/ok"; -import { notFound } from "@http/fns/response/not_found"; +import { badRequest } from "@http/response/bad-request"; +import { seeOther } from "@http/response/see-other"; +import { ok } from "@http/response/ok"; +import { notFound } from "@http/response/not-found"; import { renderHTML } from "../../../lib/render_html.tsx"; export async function POST(req: Request, match: URLPatternResult) { diff --git a/routes/todo/:listId/index.tsx b/routes/todo/:listId/index.tsx index e17b0f2..d2e0624 100644 --- a/routes/todo/:listId/index.tsx +++ b/routes/todo/:listId/index.tsx @@ -5,9 +5,9 @@ import { writeItem } from "../_lib/data.ts"; import { TodoListView } from "../_components/TodoListView.tsx"; import { TodoItemAdded } from "../_components/TodoItemView.tsx"; import { FRAGMENT_RENDER_OPTIONS } from "../../../config_fragment.ts"; -import { badRequest } from "@http/fns/response/bad_request"; -import { seeOther } from "@http/fns/response/see_other"; -import { forbidden } from "@http/fns/response/forbidden"; +import { badRequest } from "@http/response/bad-request"; +import { seeOther } from "@http/response/see-other"; +import { forbidden } from "@http/response/forbidden"; import { renderHTML } from "../../../lib/render_html.tsx"; export const GET = renderPage(({ req, match }) => ( diff --git a/routes/todo/_lib/data.ts b/routes/todo/_lib/data.ts index 6e5b674..e89aa30 100644 --- a/routes/todo/_lib/data.ts +++ b/routes/todo/_lib/data.ts @@ -1,4 +1,4 @@ -import { filterValues } from "@std/collections/filter_values"; +import { filterValues } from "@std/collections/filter-values"; import type { TodoListItem } from "./types.ts"; import { getItem, listItems, removeItem, setItem } from "$store"; import { newId } from "./id.ts"; diff --git a/routes/todo/index.ts b/routes/todo/index.ts index eda3c65..59c1370 100644 --- a/routes/todo/index.ts +++ b/routes/todo/index.ts @@ -1,4 +1,4 @@ -import { seeOther } from "@http/fns/response/see_other"; +import { seeOther } from "@http/response/see-other"; import { newId } from "./_lib/id.ts"; export function GET(_req: Request, match: URLPatternResult) { diff --git a/scripts/build.ts b/scripts/build.ts index 643af58..a240967 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -1,6 +1,6 @@ import * as esbuild from "esbuild"; import { denoPlugins } from "esbuild-deno-loader"; -import { fromFileUrl } from "@std/path/from_file_url"; +import { fromFileUrl } from "@std/path/from-file-url"; /** * Build the ServiceWorker script diff --git a/scripts/cache.ts b/scripts/cache.ts index 5e7517f..fa1c9f1 100644 --- a/scripts/cache.ts +++ b/scripts/cache.ts @@ -1,8 +1,8 @@ -import { ensureDir } from "@std/fs/ensure_dir"; -import { emptyDir } from "@std/fs/empty_dir"; +import { ensureDir } from "@std/fs/ensure-dir"; +import { emptyDir } from "@std/fs/empty-dir"; import { dirname } from "@std/path/dirname"; import { pooledMap } from "@std/async/pool"; -import { withFallback } from "@http/fns/with_fallback"; +import { withFallback } from "@http/route/with-fallback"; import routes from "../routes.ts"; import cached_routes from "../cached_routes.ts"; diff --git a/scripts/dev.ts b/scripts/dev.ts deleted file mode 100644 index 49a678e..0000000 --- a/scripts/dev.ts +++ /dev/null @@ -1,17 +0,0 @@ -import handler from "../handler.ts"; -import { buildServiceWorker } from "./build.ts"; -import { generateCron, generateRoutes } from "./gen.ts"; -import init from "@http/fns/hosting/init_localhost"; -import initCron from "../cron.ts"; -import generateQuote from "../routes/quote/_cron/generate_quote.ts"; - -await generateRoutes(); -await generateCron(); - -await buildServiceWorker(); - -await generateQuote(); - -await initCron(); - -await Deno.serve(await init(handler)).finished; diff --git a/scripts/discover_routes.ts b/scripts/discover_routes.ts index aae4851..5cca725 100644 --- a/scripts/discover_routes.ts +++ b/scripts/discover_routes.ts @@ -1,5 +1,5 @@ -import { discoverRoutes } from "@http/fns/discover_routes"; -import freshPathMapper from "@http/fns/fresh/path_mapper"; +import { discoverRoutes } from "@http/discovery/discover-routes"; +import freshPathMapper from "@http/discovery/fresh-path-mapper"; await discoverRoutes({ fileRootUrl: import.meta.resolve("../routes"), diff --git a/scripts/gen.ts b/scripts/gen.ts index 25a96bb..5fbd570 100644 --- a/scripts/gen.ts +++ b/scripts/gen.ts @@ -1,7 +1,7 @@ import { type GenerateOptions, generateRoutesModule, -} from "@http/fns/generate_routes_module"; +} from "@http/generate/generate-routes-module"; import { generateCronModule } from "../lib/generate_cron_module.ts"; type Opts = Pick< @@ -22,10 +22,8 @@ export function generateRoutes(opts: Opts = defaultOpts) { pattern: "/", fileRootUrl: import.meta.resolve("../routes"), moduleOutUrl: import.meta.resolve("../routes.ts"), - pathMapper: "@http/fns/fresh/path_mapper", + pathMapper: "@http/discovery/fresh-path-mapper", routeMapper: import.meta.resolve("../lib/route_mapper.ts"), - httpFns: "@http/fns/", - jsr: true, ...opts, }); } diff --git a/service_worker/routes.ts b/service_worker/routes.ts index 296d983..0705cb5 100644 --- a/service_worker/routes.ts +++ b/service_worker/routes.ts @@ -1,5 +1,5 @@ -import { byPattern } from "@http/fns/by_pattern"; -import { cascade } from "@http/fns/cascade"; +import { byPattern } from "@http/route/by-pattern"; +import { cascade } from "@http/route/cascade"; import calc_eval from "../routes/calc/eval.tsx"; export default cascade(