From 16239e3813c48fd885eb899be62d83b9fa8e1c75 Mon Sep 17 00:00:00 2001 From: Okiki Ojo Date: Sun, 6 Aug 2023 05:12:33 +0000 Subject: [PATCH] feat: improved error checking --- .devcontainer/devcontainer.json | 7 ++ deno.lock | 133 +++++++++++++++----------------- mod.ts | 50 +++++++++--- 3 files changed, 108 insertions(+), 82 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6763178..fcf22bb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,5 +4,12 @@ "ghcr.io/devcontainers-contrib/features/deno:1": { "version": "latest" } + }, + "customizations": { + "vscode": { + "extensions": [ + "denoland.vscode-deno" + ] + } } } \ No newline at end of file diff --git a/deno.lock b/deno.lock index ecd5f14..6b005d7 100644 --- a/deno.lock +++ b/deno.lock @@ -91,52 +91,52 @@ "https://deno.land/std@0.193.0/streams/write_all.ts": "aec90152978581ea62d56bb53a5cbf487e6a89c902f87c5969681ffbdf32b998", "https://deno.land/std@0.193.0/streams/writer_from_stream_writer.ts": "07c7ee025151a190f37fc42cbb01ff93afc949119ebddc6e0d0df14df1bf6950", "https://deno.land/std@0.193.0/streams/zip_readable_streams.ts": "a9d81aa451240f79230add674809dbee038d93aabe286e2d9671e66591fc86ca", - "https://deno.land/std@0.196.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3", - "https://deno.land/std@0.196.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", - "https://deno.land/std@0.196.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", - "https://deno.land/std@0.196.0/bytes/copy.ts": "939d89e302a9761dcf1d9c937c7711174ed74c59eef40a1e4569a05c9de88219", - "https://deno.land/std@0.196.0/io/buffer.ts": "4d6883daeb2e698579c4064170515683d69f40f3de019bfe46c5cf31e74ae793", - "https://deno.land/std@0.196.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", - "https://deno.land/std@0.196.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", - "https://deno.land/std@0.196.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0", - "https://deno.land/std@0.196.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000", - "https://deno.land/std@0.196.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1", - "https://deno.land/std@0.196.0/path/mod.ts": "f065032a7189404fdac3ad1a1551a9ac84751d2f25c431e101787846c86c79ef", - "https://deno.land/std@0.196.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d", - "https://deno.land/std@0.196.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1", - "https://deno.land/std@0.196.0/path/win32.ts": "4fca292f8d116fd6d62f243b8a61bd3d6835a9f0ede762ba5c01afe7c3c0aa12", - "https://deno.land/std@0.196.0/yaml/_error.ts": "b59e2c76ce5a47b1b9fa0ff9f96c1dd92ea1e1b17ce4347ece5944a95c3c1a84", - "https://deno.land/std@0.196.0/yaml/_loader/loader.ts": "47b9592efcb390b58b1903cc471bfdf1fc71a0d2d2b31e37b5cae7d8804c7aed", - "https://deno.land/std@0.196.0/yaml/_loader/loader_state.ts": "0841870b467169269d7c2dfa75cd288c319bc06f65edd9e42c29e5fced91c7a4", - "https://deno.land/std@0.196.0/yaml/_mark.ts": "dcd8585dee585e024475e9f3fe27d29740670fb64ebb970388094cad0fc11d5d", - "https://deno.land/std@0.196.0/yaml/_state.ts": "ef03d55ec235d48dcfbecc0ab3ade90bfae69a61094846e08003421c2cf5cfc6", - "https://deno.land/std@0.196.0/yaml/_type/binary.ts": "d34d8c8d8ed521e270cfede3401c425b971af4f6c69da1e2cb32b172d42c7da7", - "https://deno.land/std@0.196.0/yaml/_type/bool.ts": "5bfa75da84343d45347b521ba4e5aeace9fe6f53447405290d53315a3fc20e66", - "https://deno.land/std@0.196.0/yaml/_type/float.ts": "056bd3cb9c5586238b20517511014fb24b0e36f98f9f6073e12da308b6b9808a", - "https://deno.land/std@0.196.0/yaml/_type/function.ts": "ff574fe84a750695302864e1c31b93f12d14ada4bde79a5f93197fc33ad17471", - "https://deno.land/std@0.196.0/yaml/_type/int.ts": "563ad074f0fa7aecf6b6c3d84135bcc95a8269dcc15de878de20ce868fd773fa", - "https://deno.land/std@0.196.0/yaml/_type/map.ts": "7b105e4ab03a361c61e7e335a0baf4d40f06460b13920e5af3fb2783a1464000", - "https://deno.land/std@0.196.0/yaml/_type/merge.ts": "8192bf3e4d637f32567917f48bb276043da9cf729cf594e5ec191f7cd229337e", - "https://deno.land/std@0.196.0/yaml/_type/mod.ts": "060e2b3d38725094b77ea3a3f05fc7e671fced8e67ca18e525be98c4aa8f4bbb", - "https://deno.land/std@0.196.0/yaml/_type/nil.ts": "606e8f0c44d73117c81abec822f89ef81e40f712258c74f186baa1af659b8887", - "https://deno.land/std@0.196.0/yaml/_type/omap.ts": "cfe59a294726f5cea705c39a61fd2b08199cf48f4ccd6b040cb550ec0f38d0a1", - "https://deno.land/std@0.196.0/yaml/_type/pairs.ts": "0032fdfe57558d21696a4f8cf5b5cfd1f698743177080affc18629685c905666", - "https://deno.land/std@0.196.0/yaml/_type/regexp.ts": "1ce118de15b2da43b4bd8e4395f42d448b731acf3bdaf7c888f40789f9a95f8b", - "https://deno.land/std@0.196.0/yaml/_type/seq.ts": "95333abeec8a7e4d967b8c8328b269e342a4bbdd2585395549b9c4f58c8533a2", - "https://deno.land/std@0.196.0/yaml/_type/set.ts": "f28ba44e632ef2a6eb580486fd47a460445eeddbdf1dbc739c3e62486f566092", - "https://deno.land/std@0.196.0/yaml/_type/str.ts": "a67a3c6e429d95041399e964015511779b1130ea5889fa257c48457bd3446e31", - "https://deno.land/std@0.196.0/yaml/_type/timestamp.ts": "706ea80a76a73e48efaeb400ace087da1f927647b53ad6f754f4e06d51af087f", - "https://deno.land/std@0.196.0/yaml/_type/undefined.ts": "94a316ca450597ccbc6750cbd79097ad0d5f3a019797eed3c841a040c29540ba", - "https://deno.land/std@0.196.0/yaml/_utils.ts": "26b311f0d42a7ce025060bd6320a68b50e52fd24a839581eb31734cd48e20393", - "https://deno.land/std@0.196.0/yaml/parse.ts": "1fbbda572bf3fff578b6482c0d8b85097a38de3176bf3ab2ca70c25fb0c960ef", - "https://deno.land/std@0.196.0/yaml/schema.ts": "96908b78dc50c340074b93fc1598d5e7e2fe59103f89ff81e5a49b2dedf77a67", - "https://deno.land/std@0.196.0/yaml/schema/core.ts": "fa406f18ceedc87a50e28bb90ec7a4c09eebb337f94ef17468349794fa828639", - "https://deno.land/std@0.196.0/yaml/schema/default.ts": "0047e80ae8a4a93293bc4c557ae8a546aabd46bb7165b9d9b940d57b4d88bde9", - "https://deno.land/std@0.196.0/yaml/schema/extended.ts": "0784416bf062d20a1626b53c03380e265b3e39b9409afb9f4cb7d659fd71e60d", - "https://deno.land/std@0.196.0/yaml/schema/failsafe.ts": "d219ab5febc43f770917d8ec37735a4b1ad671149846cbdcade767832b42b92b", - "https://deno.land/std@0.196.0/yaml/schema/json.ts": "5f41dd7c2f1ad545ef6238633ce9ee3d444dfc5a18101e1768bd5504bf90e5e5", - "https://deno.land/std@0.196.0/yaml/schema/mod.ts": "4472e827bab5025e92bc2eb2eeefa70ecbefc64b2799b765c69af84822efef32", - "https://deno.land/std@0.196.0/yaml/type.ts": "1aabb8e0a3f4229ce0a3526256f68826d9bdf65a36c8a3890ead8011fcba7670", + "https://deno.land/std@0.197.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3", + "https://deno.land/std@0.197.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", + "https://deno.land/std@0.197.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", + "https://deno.land/std@0.197.0/bytes/copy.ts": "939d89e302a9761dcf1d9c937c7711174ed74c59eef40a1e4569a05c9de88219", + "https://deno.land/std@0.197.0/io/buffer.ts": "4d6883daeb2e698579c4064170515683d69f40f3de019bfe46c5cf31e74ae793", + "https://deno.land/std@0.197.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", + "https://deno.land/std@0.197.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", + "https://deno.land/std@0.197.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0", + "https://deno.land/std@0.197.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000", + "https://deno.land/std@0.197.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1", + "https://deno.land/std@0.197.0/path/mod.ts": "f065032a7189404fdac3ad1a1551a9ac84751d2f25c431e101787846c86c79ef", + "https://deno.land/std@0.197.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d", + "https://deno.land/std@0.197.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1", + "https://deno.land/std@0.197.0/path/win32.ts": "4fca292f8d116fd6d62f243b8a61bd3d6835a9f0ede762ba5c01afe7c3c0aa12", + "https://deno.land/std@0.197.0/yaml/_error.ts": "b59e2c76ce5a47b1b9fa0ff9f96c1dd92ea1e1b17ce4347ece5944a95c3c1a84", + "https://deno.land/std@0.197.0/yaml/_loader/loader.ts": "47b9592efcb390b58b1903cc471bfdf1fc71a0d2d2b31e37b5cae7d8804c7aed", + "https://deno.land/std@0.197.0/yaml/_loader/loader_state.ts": "0841870b467169269d7c2dfa75cd288c319bc06f65edd9e42c29e5fced91c7a4", + "https://deno.land/std@0.197.0/yaml/_mark.ts": "dcd8585dee585e024475e9f3fe27d29740670fb64ebb970388094cad0fc11d5d", + "https://deno.land/std@0.197.0/yaml/_state.ts": "ef03d55ec235d48dcfbecc0ab3ade90bfae69a61094846e08003421c2cf5cfc6", + "https://deno.land/std@0.197.0/yaml/_type/binary.ts": "d34d8c8d8ed521e270cfede3401c425b971af4f6c69da1e2cb32b172d42c7da7", + "https://deno.land/std@0.197.0/yaml/_type/bool.ts": "5bfa75da84343d45347b521ba4e5aeace9fe6f53447405290d53315a3fc20e66", + "https://deno.land/std@0.197.0/yaml/_type/float.ts": "056bd3cb9c5586238b20517511014fb24b0e36f98f9f6073e12da308b6b9808a", + "https://deno.land/std@0.197.0/yaml/_type/function.ts": "ff574fe84a750695302864e1c31b93f12d14ada4bde79a5f93197fc33ad17471", + "https://deno.land/std@0.197.0/yaml/_type/int.ts": "563ad074f0fa7aecf6b6c3d84135bcc95a8269dcc15de878de20ce868fd773fa", + "https://deno.land/std@0.197.0/yaml/_type/map.ts": "7b105e4ab03a361c61e7e335a0baf4d40f06460b13920e5af3fb2783a1464000", + "https://deno.land/std@0.197.0/yaml/_type/merge.ts": "8192bf3e4d637f32567917f48bb276043da9cf729cf594e5ec191f7cd229337e", + "https://deno.land/std@0.197.0/yaml/_type/mod.ts": "060e2b3d38725094b77ea3a3f05fc7e671fced8e67ca18e525be98c4aa8f4bbb", + "https://deno.land/std@0.197.0/yaml/_type/nil.ts": "606e8f0c44d73117c81abec822f89ef81e40f712258c74f186baa1af659b8887", + "https://deno.land/std@0.197.0/yaml/_type/omap.ts": "cfe59a294726f5cea705c39a61fd2b08199cf48f4ccd6b040cb550ec0f38d0a1", + "https://deno.land/std@0.197.0/yaml/_type/pairs.ts": "0032fdfe57558d21696a4f8cf5b5cfd1f698743177080affc18629685c905666", + "https://deno.land/std@0.197.0/yaml/_type/regexp.ts": "1ce118de15b2da43b4bd8e4395f42d448b731acf3bdaf7c888f40789f9a95f8b", + "https://deno.land/std@0.197.0/yaml/_type/seq.ts": "95333abeec8a7e4d967b8c8328b269e342a4bbdd2585395549b9c4f58c8533a2", + "https://deno.land/std@0.197.0/yaml/_type/set.ts": "f28ba44e632ef2a6eb580486fd47a460445eeddbdf1dbc739c3e62486f566092", + "https://deno.land/std@0.197.0/yaml/_type/str.ts": "a67a3c6e429d95041399e964015511779b1130ea5889fa257c48457bd3446e31", + "https://deno.land/std@0.197.0/yaml/_type/timestamp.ts": "706ea80a76a73e48efaeb400ace087da1f927647b53ad6f754f4e06d51af087f", + "https://deno.land/std@0.197.0/yaml/_type/undefined.ts": "94a316ca450597ccbc6750cbd79097ad0d5f3a019797eed3c841a040c29540ba", + "https://deno.land/std@0.197.0/yaml/_utils.ts": "26b311f0d42a7ce025060bd6320a68b50e52fd24a839581eb31734cd48e20393", + "https://deno.land/std@0.197.0/yaml/parse.ts": "1fbbda572bf3fff578b6482c0d8b85097a38de3176bf3ab2ca70c25fb0c960ef", + "https://deno.land/std@0.197.0/yaml/schema.ts": "96908b78dc50c340074b93fc1598d5e7e2fe59103f89ff81e5a49b2dedf77a67", + "https://deno.land/std@0.197.0/yaml/schema/core.ts": "fa406f18ceedc87a50e28bb90ec7a4c09eebb337f94ef17468349794fa828639", + "https://deno.land/std@0.197.0/yaml/schema/default.ts": "0047e80ae8a4a93293bc4c557ae8a546aabd46bb7165b9d9b940d57b4d88bde9", + "https://deno.land/std@0.197.0/yaml/schema/extended.ts": "0784416bf062d20a1626b53c03380e265b3e39b9409afb9f4cb7d659fd71e60d", + "https://deno.land/std@0.197.0/yaml/schema/failsafe.ts": "d219ab5febc43f770917d8ec37735a4b1ad671149846cbdcade767832b42b92b", + "https://deno.land/std@0.197.0/yaml/schema/json.ts": "5f41dd7c2f1ad545ef6238633ce9ee3d444dfc5a18101e1768bd5504bf90e5e5", + "https://deno.land/std@0.197.0/yaml/schema/mod.ts": "4472e827bab5025e92bc2eb2eeefa70ecbefc64b2799b765c69af84822efef32", + "https://deno.land/std@0.197.0/yaml/type.ts": "1aabb8e0a3f4229ce0a3526256f68826d9bdf65a36c8a3890ead8011fcba7670", "https://deno.land/x/cors@v1.2.2/abcCors.ts": "cdf83a7eaa69a1bf3ab910d18b9422217902fac47601adcaf0afac5a61845d48", "https://deno.land/x/cors@v1.2.2/attainCors.ts": "7d6aba0f942495cc31119604e0895c9bb8edd8f8baa7fe78e6c655bd0b4cbf59", "https://deno.land/x/cors@v1.2.2/cors.ts": "0e2d9167e3685f9bcf48f565e312b6e1883fa458f7337e5ce7bc2e3b29767980", @@ -178,39 +178,17 @@ "https://deno.land/x/path_to_regexp@v6.2.1/index.ts": "894060567837bae8fc9c5cbd4d0a05e9024672083d5883b525c031eea940e556", "https://esm.sh/@amoutonbrady/lz-string@0.1.0": "fe80913334aa57bb64d5127a855f90f5527e7bbf64c5b627304a55fc6b5c3ee2", "https://esm.sh/@stefanprobst/remark-shiki@2.2.1": "2ce9cb0918b0e75cb456603169de2abe57cefc683d0fd47d3a1bb7baf6df2fe5", - "https://esm.sh/rehype-raw@6.1.1": "3d47f840027aaec6187c13222e0cd34b0e2503f31f3949ad3e719fd6d94fd527", + "https://esm.sh/rehype-raw@6.1.1": "52f14fa07dfb2498ef6d24b634bbfceb569fc398568c00d53dbc377ad963868b", "https://esm.sh/rehype-stringify@9.0.3": "ac99c749744048282d25689fd7d896958b4206456bc37b53bc85cfce1286c34e", "https://esm.sh/remark-gfm@3.0.1": "665786707831e17f9f14e6a029c3cd00491d76c0d9bfae7a53978de3e6e9ebfb", "https://esm.sh/remark-parse@10.0.2": "74ae3bfb72d8d19c210e68d6f34f243a7d82403db99c14e67c63e45aba61ae85", "https://esm.sh/remark-rehype@10.1.0": "f76689dc1ac61b3908e8cd9d33548d870d894b8b68a94ef24ff9dece781d7fdc", - "https://esm.sh/typescript@5.1.6": "9401d2b334bac752a28f8df2a1e5255e1ab32f550db48d7f73746a56c67dcef8", + "https://esm.sh/typescript@5.1.6": "99fc3235ceb672dcd6126a5eff12b67754740f1ffab78ab7162899b184a5145d", "https://esm.sh/unified@10.1.2": "9742c7de1dd3c0b17a1024bbd122ccd9655330ed8c7f634d9bffda8e48531718", - "https://esm.sh/v129/buffer-from@1.1.2/denonext/buffer-from.mjs": "078451542b62cb4261c01a01ff7e9bc0f94bef4eb710831d40e1f92c4dfe3883", - "https://esm.sh/v129/comma-separated-tokens@2.0.3/denonext/comma-separated-tokens.mjs": "ad5df8a36487e0a63d15bbbb6bab8b153e08583d0d5eb6d0058cd0fc619252e0", - "https://esm.sh/v129/hast-util-from-parse5@7.1.2/denonext/hast-util-from-parse5.mjs": "217d345c03b943692facd299a948bcab4a74a9275b142cab1985a40de4e05c05", - "https://esm.sh/v129/hast-util-parse-selector@3.1.1/denonext/hast-util-parse-selector.mjs": "df576c8298a048d9aad89506f5884db91bc249bb6e221b9fd3b228eb40980a62", - "https://esm.sh/v129/hast-util-raw@7.2.3/denonext/hast-util-raw.mjs": "c3ce13860ae7bb5bf7e56ec03160a077452f7ad2165191656afe39e535c24849", - "https://esm.sh/v129/hast-util-to-parse5@7.1.0/denonext/hast-util-to-parse5.mjs": "321b6af153c81e5c5221c87cf0427ae8101ac91de0c0c3347d1c5daad9c59b17", - "https://esm.sh/v129/hastscript@7.2.0/denonext/hastscript.mjs": "8998b04df73b0edcefcf44b2676446e7b296525dc2ab26b39d2cdc450c932765", - "https://esm.sh/v129/html-void-elements@2.0.1/denonext/html-void-elements.mjs": "10f57d4f9d680bf2de32538d6aaf879f20d4ee02dd57879aa232319d6c984f54", - "https://esm.sh/v129/node_inspector.js": "c45566d90f93c4a12cc70cb4de9b8c926fa6250ca63e1483c71d62237d78777c", - "https://esm.sh/v129/parse5@6.0.1/denonext/lib/parser.js": "7b1d88ec671395f2523e0e2ddec282bdc78bbca43835416c6bca5fc079bb317e", - "https://esm.sh/v129/property-information@6.2.0/denonext/property-information.mjs": "c36042799161605d2ba2af318abf697a41e77e7ef5c80f5740de470db7776b9c", - "https://esm.sh/v129/rehype-raw@6.1.1/denonext/rehype-raw.mjs": "392939841f18281830f86d427c71bc6bba890ac98d605f711ecd73aff1948f6f", - "https://esm.sh/v129/source-map-support@0.5.21/denonext/source-map-support.mjs": "0e8f4e6a007c1b74c4f23d6e84d514cc5662f181cf38b822a3786d0ba1033d64", - "https://esm.sh/v129/source-map@0.6.1/denonext/source-map.mjs": "ccff3bb06dea7c01a2c83cf12113697592e418fd06b55ae2bb4cb0a4e51a98b8", - "https://esm.sh/v129/space-separated-tokens@2.0.2/denonext/space-separated-tokens.mjs": "f30773a9959cacfe7511c250e5d125a9f88ee00d3aef6e87b4d17fe49806b276", - "https://esm.sh/v129/typescript@5.1.6/denonext/typescript.mjs": "c77f6ade017f0c3e5826d44fe3f05c9b56298e9e2a3977d175708dedc2982dae", - "https://esm.sh/v129/unist-util-is@5.2.1/denonext/unist-util-is.mjs": "771abea65db57c71e2a3d98200242c362337617e63881fc9954e891dde32277c", - "https://esm.sh/v129/unist-util-position@4.0.4/denonext/unist-util-position.mjs": "be87a00f3663c09267443ef900692719014d966ef84969cb9ad7b9cfc4cd6157", - "https://esm.sh/v129/unist-util-visit-parents@5.1.3/denonext/unist-util-visit-parents.mjs": "27c8ec6b5e26c8a87d811eb79028478547bea53327ecf30f31d1e7e3911b0784", - "https://esm.sh/v129/unist-util-visit@4.1.2/denonext/unist-util-visit.mjs": "b42a79d035f9afff975a0c302185386cfc7dd0f4fc30db055a84a8296bff39ee", - "https://esm.sh/v129/vfile-location@4.1.0/denonext/vfile-location.mjs": "aa64a017e8059406f649f12a564162b61f1fa6ac0e4498c250e4309a9bc617bf", - "https://esm.sh/v129/web-namespaces@2.0.1/denonext/web-namespaces.mjs": "bc6ee363bbe40abddca68678e849584981176d9bde3728b4c5d47a5241dac7bf", - "https://esm.sh/v129/zwitch@2.0.4/denonext/zwitch.mjs": "c0e8c246a1f38b425335ea78cc366a7801d3ef89701229a35f85a51310e6e49f", "https://esm.sh/v130/@amoutonbrady/lz-string@0.1.0/denonext/lz-string.mjs": "159ca261a05b2cc2a7e16f959bed07e9f5200dffb8a61eb2273c25870249c5f7", "https://esm.sh/v130/@stefanprobst/remark-shiki@2.2.1/denonext/remark-shiki.mjs": "cda892ea52d3cf91654115c3486f9e4be247555ee6c75061f17282432353069e", "https://esm.sh/v130/bail@2.0.2/denonext/bail.mjs": "cab740cf24417dfad8567cbb78a49ae7e492ecca299f2b3185520805aba4d073", + "https://esm.sh/v130/buffer-from@1.1.2/denonext/buffer-from.mjs": "078451542b62cb4261c01a01ff7e9bc0f94bef4eb710831d40e1f92c4dfe3883", "https://esm.sh/v130/ccount@2.0.1/denonext/ccount.mjs": "7b32092651a866fcc992c028982ce5e911356da7653baa3febb1a8ccb93e30f8", "https://esm.sh/v130/character-entities-html4@2.1.0/denonext/character-entities-html4.mjs": "0b4e64d1b0152acbeec6d854eadce6ceb2de05b0f459ad47485afa206f745f10", "https://esm.sh/v130/character-entities-legacy@3.0.0/denonext/character-entities-legacy.mjs": "5da76ada1554e4956dc6b702ba92b56a3faf158b24bf45279c522e85f5d9cd21", @@ -219,8 +197,13 @@ "https://esm.sh/v130/decode-named-character-reference@1.0.2/denonext/decode-named-character-reference.mjs": "b1394c7ef994f6f25cf1e6b9c5606921a1d63b30fb4a5c677130096ff01a88ef", "https://esm.sh/v130/escape-string-regexp@5.0.0/denonext/escape-string-regexp.mjs": "6080dd39c43a11f999a41172a27b8c58572d747d8276c039d93d4be8b21747a5", "https://esm.sh/v130/extend@3.0.2/denonext/extend.mjs": "6ab9e4890dfa54ec88fa326fca525c211141d6da72188f54e9610d1281219c9e", + "https://esm.sh/v130/hast-util-from-parse5@7.1.2/denonext/hast-util-from-parse5.mjs": "0bc6e04f40fdbe7b1bda886d39225288c6f5557d74815d2d9a22419f3c55c49b", + "https://esm.sh/v130/hast-util-parse-selector@3.1.1/denonext/hast-util-parse-selector.mjs": "df576c8298a048d9aad89506f5884db91bc249bb6e221b9fd3b228eb40980a62", + "https://esm.sh/v130/hast-util-raw@7.2.3/denonext/hast-util-raw.mjs": "ab208e78e6f6ddb38823e8ffc5cdbb107df3aa9ba6483497125487e51e2d13d4", "https://esm.sh/v130/hast-util-to-html@8.0.4/denonext/hast-util-to-html.mjs": "4fab7c60e26520389f1f4f3ab96c294b91f519181938004c4326cb09c1f1d389", + "https://esm.sh/v130/hast-util-to-parse5@7.1.0/denonext/hast-util-to-parse5.mjs": "8cd68ce62a11ee5fc6185f8a73eaa771c699078f286a889d5ed926d94baeb459", "https://esm.sh/v130/hast-util-whitespace@2.0.1/denonext/hast-util-whitespace.mjs": "0d45cf1a1b1d7ba26d5a3f2fda8c929b02ef701786e656ade327d8c3f7b390bb", + "https://esm.sh/v130/hastscript@7.2.0/denonext/hastscript.mjs": "786713781cc78701cb15527166216bc7d3305ef88437db7458744af9d3fe3779", "https://esm.sh/v130/html-void-elements@2.0.1/denonext/html-void-elements.mjs": "10f57d4f9d680bf2de32538d6aaf879f20d4ee02dd57879aa232319d6c984f54", "https://esm.sh/v130/is-buffer@2.0.5/denonext/is-buffer.mjs": "87d027d2c668d773b7037bd49fc1c12ed6af26b9f176aacf338c7901237b8867", "https://esm.sh/v130/is-plain-obj@4.1.0/denonext/is-plain-obj.mjs": "d3d86a7174ad7935de7b00f904b6424c103bce530c502efb7f42114cbb1a555f", @@ -273,16 +256,22 @@ "https://esm.sh/v130/micromark@3.2.0/denonext/lib/parse.js": "06948bf2586f66f4f96c12a10386a3cb20d8b72a0d738953cf5913e55ce06d16", "https://esm.sh/v130/micromark@3.2.0/denonext/lib/postprocess.js": "bc1177cff416aa55b6dfd44b7341cda767b6fee28842782f20bc50ff4cad4b88", "https://esm.sh/v130/micromark@3.2.0/denonext/lib/preprocess.js": "786db83c43e9d21f14bc37b6c05f061ca4a1db862ffed10c07ca1e6843f73fae", + "https://esm.sh/v130/node_inspector.js": "c45566d90f93c4a12cc70cb4de9b8c926fa6250ca63e1483c71d62237d78777c", "https://esm.sh/v130/parse-numeric-range@1.3.0/denonext/parse-numeric-range.mjs": "3653264a361cd54f32acf63c3f21f2e171626e13534393574cfb51b7fccfa552", + "https://esm.sh/v130/parse5@6.0.1/denonext/lib/parser.js": "7b1d88ec671395f2523e0e2ddec282bdc78bbca43835416c6bca5fc079bb317e", "https://esm.sh/v130/property-information@6.2.0/denonext/property-information.mjs": "c36042799161605d2ba2af318abf697a41e77e7ef5c80f5740de470db7776b9c", + "https://esm.sh/v130/rehype-raw@6.1.1/denonext/rehype-raw.mjs": "0a27a7eb6843c73d15bb77d230e3a1b17dedb88bbe8d5ce569eb769acf50ba9b", "https://esm.sh/v130/rehype-stringify@9.0.3/denonext/rehype-stringify.mjs": "37513e88865941a6cf52e39507e3f73c97caf7e39aea230de6ca26d64616340e", "https://esm.sh/v130/remark-gfm@3.0.1/denonext/remark-gfm.mjs": "cf0544949eb6b88f7d2dfcf6219b0fdfc33ccb8ae4e8bb173eb9a59aff61d42b", "https://esm.sh/v130/remark-parse@10.0.2/denonext/remark-parse.mjs": "5ae8f0ed28dca030e5c3226cbd0f24ab23c01813d1ee3dc0929880b99817a32b", "https://esm.sh/v130/remark-rehype@10.1.0/denonext/remark-rehype.mjs": "e744f1ccdf3a6bbbd8d7ae916149c4989edae9fa65e2a90bb1c3a636b18e1935", + "https://esm.sh/v130/source-map-support@0.5.21/denonext/source-map-support.mjs": "919e7b267c3562dbb86b1f903f4f08dcc2d01f8e81265ae84f24b01b0bf2f874", + "https://esm.sh/v130/source-map@0.6.1/denonext/source-map.mjs": "ccff3bb06dea7c01a2c83cf12113697592e418fd06b55ae2bb4cb0a4e51a98b8", "https://esm.sh/v130/space-separated-tokens@2.0.2/denonext/space-separated-tokens.mjs": "f30773a9959cacfe7511c250e5d125a9f88ee00d3aef6e87b4d17fe49806b276", "https://esm.sh/v130/stringify-entities@4.0.3/denonext/stringify-entities.mjs": "86bd540c7d057b4907424f9848969af84d635ff5e187b57c18d015c0d96c91dc", "https://esm.sh/v130/trim-lines@3.0.1/denonext/trim-lines.mjs": "f01a20253341eb2554f307ab05bc9cd93d6f33bcbb24fde2fc9fcd857564283e", "https://esm.sh/v130/trough@2.1.0/denonext/trough.mjs": "d7c1b66bf8739a28bcc6bbf17919f6b54b7b25cceabfb0e694d192232c83f1fd", + "https://esm.sh/v130/typescript@5.1.6/denonext/typescript.mjs": "1a9c8ae32394c5872ad186ace39bb522f547044f9edcc04ad551adf686d7da2b", "https://esm.sh/v130/unified@10.1.2/denonext/unified.mjs": "9051f93376e2b1c427c065813ee1185103c0d60a4c42c546534f970fbe91199f", "https://esm.sh/v130/unist-util-generated@2.0.1/denonext/unist-util-generated.mjs": "ff9c54405f6aedb39847fd975a3f528129089e74dd61e9408d5b1b09d8a13dc1", "https://esm.sh/v130/unist-util-is@5.2.1/denonext/unist-util-is.mjs": "771abea65db57c71e2a3d98200242c362337617e63881fc9954e891dde32277c", @@ -290,8 +279,10 @@ "https://esm.sh/v130/unist-util-stringify-position@3.0.3/denonext/unist-util-stringify-position.mjs": "e3b2256d68ec8d5ceeb204afe84492e69182ad264a876309a33def43aa34111d", "https://esm.sh/v130/unist-util-visit-parents@5.1.3/denonext/unist-util-visit-parents.mjs": "0b767f059a8111c7a5ae52050a7eb6d7ac4a90ef0223d5a049bf177f1b1c9992", "https://esm.sh/v130/unist-util-visit@4.1.2/denonext/unist-util-visit.mjs": "b77a640889c989aa87d92c75d5ce2735553e036784a00900f2f5ac2a7094b008", + "https://esm.sh/v130/vfile-location@4.1.0/denonext/vfile-location.mjs": "aa64a017e8059406f649f12a564162b61f1fa6ac0e4498c250e4309a9bc617bf", "https://esm.sh/v130/vfile-message@3.1.4/denonext/vfile-message.mjs": "76abbcd2afa0e61d3511799e5118c9471c4bce770e85fae04c4c0b4c74d5447f", "https://esm.sh/v130/vfile@5.3.7/denonext/vfile.mjs": "165e0f0d2c0a5db9cc1347175c75ee88bff56b143cd21216b625a3141cccbe0d", + "https://esm.sh/v130/web-namespaces@2.0.1/denonext/web-namespaces.mjs": "bc6ee363bbe40abddca68678e849584981176d9bde3728b4c5d47a5241dac7bf", "https://esm.sh/v130/zwitch@2.0.4/denonext/zwitch.mjs": "c0e8c246a1f38b425335ea78cc366a7801d3ef89701229a35f85a51310e6e49f", "https://unpkg.com/shiki@0.14.3/dist/index.browser.mjs": "e701176f99cb93cfb15f0ebbdafcc996b89fc11ade576470b2f6a3feeef22b78" } diff --git a/mod.ts b/mod.ts index 6e4f96e..10418aa 100644 --- a/mod.ts +++ b/mod.ts @@ -88,17 +88,27 @@ router ); } - // Max file size to handle - const data: TwoslashRequestOptions = type === "form-data" - ? (await value.read({ maxSize: 10000000 })).fields - : await value; - const { code, extension, ...opts } = data; + let data: TwoslashRequestOptions | undefined; + try { + // Max file size to handle + data = type === "form-data" + ? (await value.read({ maxSize: 10000000 })).fields + : await value; + } catch (e) { + console.log(e) + context.throw( + Status.BadRequest, + "Error Unable to Read Request Body" + ); + } + + const { code, extension, ...opts } = data! ?? {}; // let tsModule: typeof Typescript; // if (version) { // tsModule = await import(`https://esm.sh/typescript@${versionNumber}`).default; // } - + const twoslash = await twoslasher(code, extension, opts); context.response.body = twoslash; }) @@ -130,12 +140,30 @@ router params.get("option")! || "{}"; - const decodedQuery: TwoslashRequestOptions = Object.assign( - { code: codeParam, extension: extensionParam }, - JSON.parse(optionsParam), - ); - const { code, extension = "ts", ...opts } = decodedQuery; + let decodedQuery: TwoslashRequestOptions = { + code: codeParam!, + extension: extensionParam!, + }; + try { + const optsObj = JSON.parse(optionsParam) + if (typeof optsObj !== "object" || Array.isArray(optsObj)) { + throw new Error("Options Query Parameter must be an Object.") + } + + decodedQuery = Object.assign( + { code: codeParam, extension: extensionParam }, + optsObj, + ); + } catch (e) { + console.log(e) + context.throw( + Status.BadRequest, + `Invalid JSON Object for the Options parameter`, + ); + } + + const { code, extension = "ts", ...opts } = decodedQuery; const twoslash = await twoslasher(code, extension, opts); console.log("twoslash ", twoslash); context.response.body = twoslash; -- 2.51.2