From 907234adf418df974b66b00ce99710632e6aee67 Mon Sep 17 00:00:00 2001 From: Amit Upadhyay Date: Fri, 16 Feb 2024 16:59:08 +0530 Subject: [PATCH 1/3] renamed redirect() to permanent_redirect() And added temprorary_redirect(). Redirects in auth flow should be temporary_redirects, not permanent. Permanent redirect should only be used for our redirect feature. --- fastn-core/src/auth/discord.rs | 4 +--- fastn-core/src/auth/email_password/confirm_email.rs | 13 +++++-------- fastn-core/src/auth/email_password/onboarding.rs | 3 +-- fastn-core/src/auth/email_password/resend_email.rs | 3 +-- fastn-core/src/auth/github/mod.rs | 8 ++++---- fastn-core/src/auth/twitter.rs | 4 +--- fastn-core/src/commands/serve.rs | 2 +- fastn-core/src/http.rs | 10 ++++++---- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/fastn-core/src/auth/discord.rs b/fastn-core/src/auth/discord.rs index a49c4c1ebf..b197532d6f 100644 --- a/fastn-core/src/auth/discord.rs +++ b/fastn-core/src/auth/discord.rs @@ -64,9 +64,7 @@ pub async fn login(req: actix_web::HttpRequest) -> fastn_core::Result fastn_core::Result// diff --git a/fastn-core/src/http.rs b/fastn-core/src/http.rs index 7fae44713c..984f7ddcb6 100644 --- a/fastn-core/src/http.rs +++ b/fastn-core/src/http.rs @@ -58,10 +58,12 @@ pub fn ok(data: Vec) -> fastn_core::http::Response { actix_web::HttpResponse::Ok().body(data) } -pub fn redirect(url: String) -> fastn_core::http::Response { - actix_web::HttpResponse::PermanentRedirect() - .insert_header(("LOCATION", url)) - .finish() +pub fn permanent_redirect(url: String) -> fastn_core::http::Response { + redirect_with_code(url, 308) +} + +pub fn temporary_redirect(url: String) -> fastn_core::http::Response { + redirect_with_code(url, 307) } pub fn redirect_with_code(url: String, code: i32) -> fastn_core::http::Response { From 615bbe588d30ba20b6fff652fe1e6b446acd47a1 Mon Sep 17 00:00:00 2001 From: Harsh Singh Date: Fri, 16 Feb 2024 16:52:35 +0530 Subject: [PATCH 2/3] interpolate environment variables in endpoint defined in fastn.url-mappings --- fastn-core/src/config/mod.rs | 9 + fastn-core/src/utils.rs | 45 ++++ ...68397A7E3F168E807119C8D73E375734010259.js} | 6 + .../tests/08-static-assets/output/index.html | 2 +- ...7C76B4EF66302B96447D220BBCE10F8122B342.js} | 6 + .../tests/09-markdown-pages/output/index.html | 2 +- ...2E03E5AE70ACD4DBF17D461BF66523DD110CC5.js} | 6 + .../output/guide/install/index.html | 2 +- fastn-core/tests/17-sitemap/output/index.html | 2 +- .../17-sitemap/output/install/index.html | 2 +- ...AADC9D400114E3917D4F8AEFCFB10D1765DAAB.js} | 6 + .../tests/19-offline-build/output/index.html | 2 +- fastn-core/tests/21-http-endpoint/cmd.p1 | 2 +- .../tests/21-http-endpoint/input/FASTN.ftd | 2 +- .../output/.fastn/config.json | 216 ------------------ .../tests/21-http-endpoint/output/FASTN.ftd | 2 +- ...0B3EF2BDE8DBABABFB476CED9CCAE7550067A3.js} | 6 + .../tests/21-http-endpoint/output/index.html | 2 +- .../21-http-endpoint/output/manifest.json | 6 +- 19 files changed, 97 insertions(+), 229 deletions(-) rename fastn-core/tests/08-static-assets/output/{default-D664697CA52D6C29B1306A9A9D12A7ACF13B0529B76437F61F5AEDDA74233BC7.js => default-A3F82511B3E56D2CD08DBB929668397A7E3F168E807119C8D73E375734010259.js} (99%) rename fastn-core/tests/09-markdown-pages/output/{default-0122ED5D3AFF7F8489CA441E516970D33CAB03A8E8A7009F99B1F09460A36AD4.js => default-67B65AF29D66B906BAE293F4937C76B4EF66302B96447D220BBCE10F8122B342.js} (99%) rename fastn-core/tests/17-sitemap/output/{default-0FF06CE88CB4E828DE3A913F3D083D788EDE5599561936AD95C3A63370C8B19D.js => default-D473FE22CBCC050EFA221DFE772E03E5AE70ACD4DBF17D461BF66523DD110CC5.js} (99%) rename fastn-core/tests/19-offline-build/output/{default-E53437B404B7748568BBA51316B50190DFF738680ACCD891F6684BBB0CFBF31D.js => default-84E5DFDBAA4766EAF977826708AADC9D400114E3917D4F8AEFCFB10D1765DAAB.js} (99%) delete mode 100644 fastn-core/tests/21-http-endpoint/output/.fastn/config.json rename fastn-core/tests/21-http-endpoint/output/{default-1CB230847A396730B0DB3BA55C390AFF868BA98D37975743373DACDF37606759.js => default-0CA435A480F9408892ACA383C50B3EF2BDE8DBABABFB476CED9CCAE7550067A3.js} (99%) diff --git a/fastn-core/src/config/mod.rs b/fastn-core/src/config/mod.rs index 7ce001b3aa..b4cb3a7005 100644 --- a/fastn-core/src/config/mod.rs +++ b/fastn-core/src/config/mod.rs @@ -1180,6 +1180,15 @@ impl Config { apps }; + config.package.endpoints = { + for endpoint in &mut config.package.endpoints { + endpoint.endpoint = + fastn_core::utils::interpolate_env_vars(&config.ds, &endpoint.endpoint).await?; + } + + config.package.endpoints + }; + config .all_packages .insert(package.name.to_string(), package.to_owned()); diff --git a/fastn-core/src/utils.rs b/fastn-core/src/utils.rs index e959a16282..0e87f34abb 100644 --- a/fastn-core/src/utils.rs +++ b/fastn-core/src/utils.rs @@ -1072,3 +1072,48 @@ pub(crate) fn is_static_path(path: &str) -> bool { None => false, } } + +static VARIABLE_INTERPOLATION_RGX: once_cell::sync::Lazy = + once_cell::sync::Lazy::new(|| regex::Regex::new(r"\$\{([^}]+)\}").unwrap()); + +pub(crate) async fn interpolate_env_vars( + ds: &fastn_ds::DocumentStore, + endpoint: &str, +) -> fastn_core::Result { + let mut result = String::new(); + let mut last_end = 0; + + for captures in VARIABLE_INTERPOLATION_RGX.captures_iter(endpoint) { + let capture = captures.get(0).unwrap(); + let start = capture.start(); + let end = capture.end(); + result.push_str(&endpoint[last_end..start]); + + let key = captures.get(1).unwrap().as_str(); + + let value = match key { + key if key.starts_with("env.") => { + let env_key = key.trim_start_matches("env."); + ds.env(env_key).await.map_err(|e| { + fastn_core::error::Error::generic(format!( + "Failed to interpolate environment variable '{}' in endpoint.: {e}", + env_key + )) + })? + } + _ => { + return Err(fastn_core::error::Error::generic(format!( + "Failed to interpolate unknown variable '{}' in endpoint.", + key + ))) + } + }; + + result.push_str(&value); + + last_end = end; + } + + result.push_str(&endpoint[last_end..]); + Ok(result) +} diff --git a/fastn-core/tests/08-static-assets/output/default-D664697CA52D6C29B1306A9A9D12A7ACF13B0529B76437F61F5AEDDA74233BC7.js b/fastn-core/tests/08-static-assets/output/default-A3F82511B3E56D2CD08DBB929668397A7E3F168E807119C8D73E375734010259.js similarity index 99% rename from fastn-core/tests/08-static-assets/output/default-D664697CA52D6C29B1306A9A9D12A7ACF13B0529B76437F61F5AEDDA74233BC7.js rename to fastn-core/tests/08-static-assets/output/default-A3F82511B3E56D2CD08DBB929668397A7E3F168E807119C8D73E375734010259.js index 644d9a2018..9296645bb3 100644 --- a/fastn-core/tests/08-static-assets/output/default-D664697CA52D6C29B1306A9A9D12A7ACF13B0529B76437F61F5AEDDA74233BC7.js +++ b/fastn-core/tests/08-static-assets/output/default-A3F82511B3E56D2CD08DBB929668397A7E3F168E807119C8D73E375734010259.js @@ -4798,6 +4798,12 @@ const ftd = (function () { redirect, }; + if (method === "GET") { + console.warn("Method `GET` is not yet supported."); + return; + } + + if (body && method !== "GET") { if (body[0] instanceof fastn.recordInstanceClass) { if (body.length !== 1) { diff --git a/fastn-core/tests/08-static-assets/output/index.html b/fastn-core/tests/08-static-assets/output/index.html index c71e1a87e0..55e13eb1f7 100644 --- a/fastn-core/tests/08-static-assets/output/index.html +++ b/fastn-core/tests/08-static-assets/output/index.html @@ -14,7 +14,7 @@ - + diff --git a/fastn-core/tests/09-markdown-pages/output/default-0122ED5D3AFF7F8489CA441E516970D33CAB03A8E8A7009F99B1F09460A36AD4.js b/fastn-core/tests/09-markdown-pages/output/default-67B65AF29D66B906BAE293F4937C76B4EF66302B96447D220BBCE10F8122B342.js similarity index 99% rename from fastn-core/tests/09-markdown-pages/output/default-0122ED5D3AFF7F8489CA441E516970D33CAB03A8E8A7009F99B1F09460A36AD4.js rename to fastn-core/tests/09-markdown-pages/output/default-67B65AF29D66B906BAE293F4937C76B4EF66302B96447D220BBCE10F8122B342.js index e0fbc0a7ea..7474389749 100644 --- a/fastn-core/tests/09-markdown-pages/output/default-0122ED5D3AFF7F8489CA441E516970D33CAB03A8E8A7009F99B1F09460A36AD4.js +++ b/fastn-core/tests/09-markdown-pages/output/default-67B65AF29D66B906BAE293F4937C76B4EF66302B96447D220BBCE10F8122B342.js @@ -4798,6 +4798,12 @@ const ftd = (function () { redirect, }; + if (method === "GET") { + console.warn("Method `GET` is not yet supported."); + return; + } + + if (body && method !== "GET") { if (body[0] instanceof fastn.recordInstanceClass) { if (body.length !== 1) { diff --git a/fastn-core/tests/09-markdown-pages/output/index.html b/fastn-core/tests/09-markdown-pages/output/index.html index 316ab3dc4a..22185ce23f 100644 --- a/fastn-core/tests/09-markdown-pages/output/index.html +++ b/fastn-core/tests/09-markdown-pages/output/index.html @@ -14,7 +14,7 @@ - + diff --git a/fastn-core/tests/17-sitemap/output/default-0FF06CE88CB4E828DE3A913F3D083D788EDE5599561936AD95C3A63370C8B19D.js b/fastn-core/tests/17-sitemap/output/default-D473FE22CBCC050EFA221DFE772E03E5AE70ACD4DBF17D461BF66523DD110CC5.js similarity index 99% rename from fastn-core/tests/17-sitemap/output/default-0FF06CE88CB4E828DE3A913F3D083D788EDE5599561936AD95C3A63370C8B19D.js rename to fastn-core/tests/17-sitemap/output/default-D473FE22CBCC050EFA221DFE772E03E5AE70ACD4DBF17D461BF66523DD110CC5.js index 5f1a7d1412..663626a98e 100644 --- a/fastn-core/tests/17-sitemap/output/default-0FF06CE88CB4E828DE3A913F3D083D788EDE5599561936AD95C3A63370C8B19D.js +++ b/fastn-core/tests/17-sitemap/output/default-D473FE22CBCC050EFA221DFE772E03E5AE70ACD4DBF17D461BF66523DD110CC5.js @@ -4798,6 +4798,12 @@ const ftd = (function () { redirect, }; + if (method === "GET") { + console.warn("Method `GET` is not yet supported."); + return; + } + + if (body && method !== "GET") { if (body[0] instanceof fastn.recordInstanceClass) { if (body.length !== 1) { diff --git a/fastn-core/tests/17-sitemap/output/guide/install/index.html b/fastn-core/tests/17-sitemap/output/guide/install/index.html index d9d0d13b47..8d0da2d44d 100644 --- a/fastn-core/tests/17-sitemap/output/guide/install/index.html +++ b/fastn-core/tests/17-sitemap/output/guide/install/index.html @@ -14,7 +14,7 @@ - + diff --git a/fastn-core/tests/17-sitemap/output/index.html b/fastn-core/tests/17-sitemap/output/index.html index e8f9ebd400..78def79f8a 100644 --- a/fastn-core/tests/17-sitemap/output/index.html +++ b/fastn-core/tests/17-sitemap/output/index.html @@ -14,7 +14,7 @@ - + diff --git a/fastn-core/tests/17-sitemap/output/install/index.html b/fastn-core/tests/17-sitemap/output/install/index.html index d9d0d13b47..8d0da2d44d 100644 --- a/fastn-core/tests/17-sitemap/output/install/index.html +++ b/fastn-core/tests/17-sitemap/output/install/index.html @@ -14,7 +14,7 @@ - + diff --git a/fastn-core/tests/19-offline-build/output/default-E53437B404B7748568BBA51316B50190DFF738680ACCD891F6684BBB0CFBF31D.js b/fastn-core/tests/19-offline-build/output/default-84E5DFDBAA4766EAF977826708AADC9D400114E3917D4F8AEFCFB10D1765DAAB.js similarity index 99% rename from fastn-core/tests/19-offline-build/output/default-E53437B404B7748568BBA51316B50190DFF738680ACCD891F6684BBB0CFBF31D.js rename to fastn-core/tests/19-offline-build/output/default-84E5DFDBAA4766EAF977826708AADC9D400114E3917D4F8AEFCFB10D1765DAAB.js index dc4298cedc..3afad0b436 100644 --- a/fastn-core/tests/19-offline-build/output/default-E53437B404B7748568BBA51316B50190DFF738680ACCD891F6684BBB0CFBF31D.js +++ b/fastn-core/tests/19-offline-build/output/default-84E5DFDBAA4766EAF977826708AADC9D400114E3917D4F8AEFCFB10D1765DAAB.js @@ -4798,6 +4798,12 @@ const ftd = (function () { redirect, }; + if (method === "GET") { + console.warn("Method `GET` is not yet supported."); + return; + } + + if (body && method !== "GET") { if (body[0] instanceof fastn.recordInstanceClass) { if (body.length !== 1) { diff --git a/fastn-core/tests/19-offline-build/output/index.html b/fastn-core/tests/19-offline-build/output/index.html index 4618e705ad..f9c6e50478 100644 --- a/fastn-core/tests/19-offline-build/output/index.html +++ b/fastn-core/tests/19-offline-build/output/index.html @@ -14,7 +14,7 @@ - + diff --git a/fastn-core/tests/21-http-endpoint/cmd.p1 b/fastn-core/tests/21-http-endpoint/cmd.p1 index 403a6fdcc2..0a979d206e 100644 --- a/fastn-core/tests/21-http-endpoint/cmd.p1 +++ b/fastn-core/tests/21-http-endpoint/cmd.p1 @@ -1,5 +1,5 @@ -- fbt: -cmd: $FBT_CWD/../target/debug/fastn --test build +cmd: REQRES="reqres.in" $FBT_CWD/../target/debug/fastn --test build output: .build -- stdout: diff --git a/fastn-core/tests/21-http-endpoint/input/FASTN.ftd b/fastn-core/tests/21-http-endpoint/input/FASTN.ftd index 7c4123d08a..58b8d8fdc9 100644 --- a/fastn-core/tests/21-http-endpoint/input/FASTN.ftd +++ b/fastn-core/tests/21-http-endpoint/input/FASTN.ftd @@ -4,4 +4,4 @@ -- fastn.url-mappings: -/api/* -> http+proxy://reqres.in/api/* +/api/* -> http+proxy://${env.REQRES}/api/* diff --git a/fastn-core/tests/21-http-endpoint/output/.fastn/config.json b/fastn-core/tests/21-http-endpoint/output/.fastn/config.json deleted file mode 100644 index b49aa356ef..0000000000 --- a/fastn-core/tests/21-http-endpoint/output/.fastn/config.json +++ /dev/null @@ -1,216 +0,0 @@ -{ - "package": "fastn-stack.github.io/http-endpoint-test", - "all_packages": { - "fastn-stack.github.io/fastn-ui": { - "files": { - "FASTN.ftd": { - "name": "FASTN.ftd", - "checksum": "22E9BA037F761093E2BEA5C9D4E33E03787661992D94BA0612BD996FFA1AAE0F", - "size": 208 - }, - "arrow-right.png": { - "name": "arrow-right.png", - "checksum": "9F08169F542CB20A17F9432290A23B35DA8E815718E13749C125E5C915398036", - "size": 264 - }, - "code.ftd": { - "name": "code.ftd", - "checksum": "55817640588F621BDE4A4850AED568085E2C1E9CBBCD7C399C0FADA7DB6E512C", - "size": 125 - }, - "create-cr.ftd": { - "name": "create-cr.ftd", - "checksum": "17C19856B09572E56A82BB37704A69F8505022A65D792CB6E4E89750E84FA263", - "size": 659 - }, - "cross.svg": { - "name": "cross.svg", - "checksum": "030E3E7DBA0BD039E86E78A1DA968F24EA0811FB1C4CAD3481E18947A3F7A1D4", - "size": 1483 - }, - "delete-icon.svg": { - "name": "delete-icon.svg", - "checksum": "52593C3DC6B757A0F683709E254559723400EC0633915866E60E5B3F6DA0922C", - "size": 2944 - }, - "delete.png": { - "name": "delete.png", - "checksum": "044778C91335EC245858A656123EF2B561558C4554B59AAAB36D2208A35C9CD7", - "size": 647 - }, - "desktop-active.svg": { - "name": "desktop-active.svg", - "checksum": "8775C6BF6DCF54FBB347C2484900F65BE08FC2E9F7A1A22F377589E53ACB57CE", - "size": 740 - }, - "desktop.svg": { - "name": "desktop.svg", - "checksum": "2F345251CAAD01E884CD37EEE0AC4E939ABD092428A9B83BDB4886892456C1C8", - "size": 740 - }, - "downarrow.svg": { - "name": "downarrow.svg", - "checksum": "3EDC5E9D3185DABE1ED80673A59B38FA26B86905585C66DAC3DB10038800DEEA", - "size": 493 - }, - "e-active.svg": { - "name": "e-active.svg", - "checksum": "21373E1D1CB66CFDBD4DC69207F6EE1737EC5375CD2061B5EB704790AE19022C", - "size": 285 - }, - "e-default.svg": { - "name": "e-default.svg", - "checksum": "C0F739A6B7182CD32FB54732DBB375D9DD880613118758B65051F19F93F8EED4", - "size": 226 - }, - "edit-icon-default.svg": { - "name": "edit-icon-default.svg", - "checksum": "3E413DAEDE33A18766C486523F19F7B3EC3C1F13E93BEAC85E503B718D0E7B93", - "size": 680 - }, - "edit-icon.svg": { - "name": "edit-icon.svg", - "checksum": "A13E52D1FCC7FD76FD39CB697432D4AC3C47290991558B63A3FDEB43C483B1E8", - "size": 590 - }, - "edit.svg": { - "name": "edit.svg", - "checksum": "7E234382BB2096A022CF12D258515210D30BE7F5D2866902D711E90592F8CB46", - "size": 676 - }, - "editor-icon.svg": { - "name": "editor-icon.svg", - "checksum": "AE8CCE7B1D9EEBE7590EF2A519453CB2059C94E230393D6E1074E0D17F605C51", - "size": 2934 - }, - "editor.ftd": { - "name": "editor.ftd", - "checksum": "E4EC691229D5AE382614B0E3E066E14C4E8FABECCE861DDDD6BC24CFF4BAFFFA", - "size": 59032 - }, - "file.svg": { - "name": "file.svg", - "checksum": "56417622D53BA855271F5A0455F841BA4E084D326C733C461900F860ECEEC162", - "size": 1512 - }, - "folder-icon.svg": { - "name": "folder-icon.svg", - "checksum": "09558AC0F284D4FF37E0B94A2275C3A988B77E465FBA15C9A61650EA57D6D903", - "size": 995 - }, - "git-pull-request.svg": { - "name": "git-pull-request.svg", - "checksum": "F86F00421FA0F656E252440C2675E78E5B952C6343D7BB161F0092C5A1728416", - "size": 1302 - }, - "image.ftd": { - "name": "image.ftd", - "checksum": "58F326B131268701961B0E1763109CAD8CB1A9D8D864720135E63A11EA26B3EC", - "size": 73 - }, - "index.ftd": { - "name": "index.ftd", - "checksum": "3088825DA1446D71924305D7B073D03294A1E7E466AF8EF9449FE0A0CDAC3683", - "size": 4040 - }, - "local-active.svg": { - "name": "local-active.svg", - "checksum": "2DDC6BB01721570A9955188F46051140A457B4776FA0B080A08030F558B8D094", - "size": 292 - }, - "local.svg": { - "name": "local.svg", - "checksum": "1D9CCBE45D0D80A9367852BEEFB7930B63FC78413076784F32E32832C3741319", - "size": 292 - }, - "m-active.svg": { - "name": "m-active.svg", - "checksum": "B43127FA9B7B528A2A0858F6CF8E35C0D74E4F810B6A0098AE832FB052CBB51A", - "size": 340 - }, - "m-default.svg": { - "name": "m-default.svg", - "checksum": "8D94D17FE48001159854B031AF5D96E9220171ACAABEA7A5514E7D19EB24CA1F", - "size": 279 - }, - "markdown.ftd": { - "name": "markdown.ftd", - "checksum": "E49C79D420F5A91ACBFD6F891D03062EE9CE9F17743180872D85BE6994E738A6", - "size": 104 - }, - "mobile-active.svg": { - "name": "mobile-active.svg", - "checksum": "EAE169027F9884E0559E95793F626EB41FE0340511E0D8BED1EC55390B8E7E04", - "size": 1493 - }, - "mobile-frame.png": { - "name": "mobile-frame.png", - "checksum": "6B5910F7EB38FFD7B0518661A2A4AF52FCBC825E3F0ADCA166A17FA92D77D98B", - "size": 42009 - }, - "mobile.svg": { - "name": "mobile.svg", - "checksum": "38B6E21D51CBD7864FA2365BB127BB86A30337574CA1DF47C9C1369DCDA8D65C", - "size": 1485 - }, - "new-file-icon.svg": { - "name": "new-file-icon.svg", - "checksum": "652F3B1C3FCD4F85821925FC5DBF7ADB0F964A3F2F530B821D5D8C5C47B2F11F", - "size": 2982 - }, - "original-status.ftd-0.2": { - "name": "original-status.ftd-0.2", - "checksum": "146E13845A43A62192CFC5CEBB46C706C97998C811F4ECFEBF10E259AFBA379E", - "size": 3306 - }, - "package-info.ftd": { - "name": "package-info.ftd", - "checksum": "DDAC4D477EAB215452C3B904C906460816AFEBE8CF1027CC1E5EA8363F99457F", - "size": 881 - }, - "refresh.svg": { - "name": "refresh.svg", - "checksum": "0BE9E00669EF7798975D06DBD704D80C1DD348D712B2FB0728836F5959CAF538", - "size": 1354 - }, - "rename.png": { - "name": "rename.png", - "checksum": "6E653D8E53E6B826ACD190A365263CD0D4E560506D436DBD3C7C688BC392BB67", - "size": 464 - }, - "right-arrow.svg": { - "name": "right-arrow.svg", - "checksum": "4F72E539073791B9C9F1A4738381A60021372A8F512FC8F4621D5A641FD7943D", - "size": 426 - }, - "server-active.svg": { - "name": "server-active.svg", - "checksum": "35B41E77D4AAA14FF83CB1761197374B4C5206DACEBBB2ECE44CE07BD5683131", - "size": 318 - }, - "server.svg": { - "name": "server.svg", - "checksum": "55E91C6C89BC3818EB771AA08F37D97FDAE9E17E8CEE9B429AD456C2A49AB935", - "size": 318 - }, - "showbar.svg": { - "name": "showbar.svg", - "checksum": "F6109ECDC65DFEFC3B371EB878638BE9D96F7325C3F67CE23D7E8A7E9A172E9E", - "size": 795 - }, - "sync.svg": { - "name": "sync.svg", - "checksum": "86D7130343B46622211A67074289D55536122FE441E27B32E612ED795B259E00", - "size": 1427 - }, - "translation-status.ftd": { - "name": "translation-status.ftd", - "checksum": "F46AF144A7CB8201D123EEE299613F2964DF64A36A5451BF67941DF990D463D2", - "size": 3168 - } - }, - "zip_url": "https://github.com/fastn-stack/fastn-ui/archive/9b154f7807d317c4f617b06726a11ca2ab0a42a1.zip", - "checksum": "01F7EA2F19DBBC720D062757D833BA3C63D282FC7111C13E9E904391EC8CDBFD" - } - } -} \ No newline at end of file diff --git a/fastn-core/tests/21-http-endpoint/output/FASTN.ftd b/fastn-core/tests/21-http-endpoint/output/FASTN.ftd index 7c4123d08a..58b8d8fdc9 100644 --- a/fastn-core/tests/21-http-endpoint/output/FASTN.ftd +++ b/fastn-core/tests/21-http-endpoint/output/FASTN.ftd @@ -4,4 +4,4 @@ -- fastn.url-mappings: -/api/* -> http+proxy://reqres.in/api/* +/api/* -> http+proxy://${env.REQRES}/api/* diff --git a/fastn-core/tests/21-http-endpoint/output/default-1CB230847A396730B0DB3BA55C390AFF868BA98D37975743373DACDF37606759.js b/fastn-core/tests/21-http-endpoint/output/default-0CA435A480F9408892ACA383C50B3EF2BDE8DBABABFB476CED9CCAE7550067A3.js similarity index 99% rename from fastn-core/tests/21-http-endpoint/output/default-1CB230847A396730B0DB3BA55C390AFF868BA98D37975743373DACDF37606759.js rename to fastn-core/tests/21-http-endpoint/output/default-0CA435A480F9408892ACA383C50B3EF2BDE8DBABABFB476CED9CCAE7550067A3.js index b81b7edca0..5bd0185cbd 100644 --- a/fastn-core/tests/21-http-endpoint/output/default-1CB230847A396730B0DB3BA55C390AFF868BA98D37975743373DACDF37606759.js +++ b/fastn-core/tests/21-http-endpoint/output/default-0CA435A480F9408892ACA383C50B3EF2BDE8DBABABFB476CED9CCAE7550067A3.js @@ -4798,6 +4798,12 @@ const ftd = (function () { redirect, }; + if (method === "GET") { + console.warn("Method `GET` is not yet supported."); + return; + } + + if (body && method !== "GET") { if (body[0] instanceof fastn.recordInstanceClass) { if (body.length !== 1) { diff --git a/fastn-core/tests/21-http-endpoint/output/index.html b/fastn-core/tests/21-http-endpoint/output/index.html index c947ca4b1f..ad8e24c4ed 100644 --- a/fastn-core/tests/21-http-endpoint/output/index.html +++ b/fastn-core/tests/21-http-endpoint/output/index.html @@ -14,7 +14,7 @@ - + diff --git a/fastn-core/tests/21-http-endpoint/output/manifest.json b/fastn-core/tests/21-http-endpoint/output/manifest.json index fbeddceb19..2ff16a511a 100644 --- a/fastn-core/tests/21-http-endpoint/output/manifest.json +++ b/fastn-core/tests/21-http-endpoint/output/manifest.json @@ -2,8 +2,8 @@ "files": { "FASTN.ftd": { "name": "FASTN.ftd", - "checksum": "C2CE66A098529553F69A4B28405B0777037EDFA90E02D4B054C0239D38FAF9FA", - "size": 141 + "checksum": "1A051A65F8DEDF8464FC2B0BC057E78D565655893F0435EE5E145EB23A667C7C", + "size": 145 }, "index.ftd": { "name": "index.ftd", @@ -12,5 +12,5 @@ } }, "zip_url": "https://codeload.github.com/fastn-stack/http-endpoint-test/zip/refs/heads/main", - "checksum": "8FE0D88CC4B265A00618574359DC902976A2B4494B950D547F7D939E7F2A25E2" + "checksum": "6B712EBA21408F2619EC7EBB3B90BAE0879A4AA451F08BD9FA54F2D34159BBE0" } From 6c1fb51e394d2c9b068beec8a53d55f3ff06f2f4 Mon Sep 17 00:00:00 2001 From: Harsh Singh Date: Fri, 16 Feb 2024 17:05:11 +0530 Subject: [PATCH 3/3] js fmt --- fastn-js/js/ftd.js | 1 - 1 file changed, 1 deletion(-) diff --git a/fastn-js/js/ftd.js b/fastn-js/js/ftd.js index 45ef9d8cda..8b5b0e6d18 100644 --- a/fastn-js/js/ftd.js +++ b/fastn-js/js/ftd.js @@ -217,7 +217,6 @@ const ftd = (function () { return; } - if (body && method !== "GET") { if (body[0] instanceof fastn.recordInstanceClass) { if (body.length !== 1) {