fastn-stack / fastn

🚧 (Alpha stage software) fastn - better way to build websites 🚧
https://fastn.com
GNU Affero General Public License v3.0
464 stars 36 forks source link

feat(pr/request-data): add support default values #1800

Closed siddhantk232 closed 6 months ago

siddhantk232 commented 6 months ago

request-data works with optional string variables and string variables with default values.

-- import: fastn/processors as pr

;; if ?code=smth in url then $code is "smth"
;; else $code is NULL
-- optional string code: 
$processor$: pr.request-data

;; if ?code=smth in url then $code is "smth"
;; else $code is "default"
-- optional string code: default
$processor$: pr.request-data

;; if ?name=smth in url then $name is "smth"
;; else $name is "default"
-- string name: default
$processor$: pr.request-data

;; if ?err=smth in url then $err is "smth"
;; else an error will be thrown by fastn
-- string err:
$processor$: pr.request-data
amitu commented 6 months ago

Write some tests also.

siddhantk232 commented 6 months ago

Write some tests also.

could you link some existing tests that I can learn from?

siddhantk232 commented 6 months ago

Added some tests. Not sure if this is the correct way to test this tho, feel like I should've gone for integration tests.

@amitu