generated from calcit-lang/calcit-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compact.cirru
39 lines (38 loc) · 1.63 KB
/
compact.cirru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{} (:package |app)
:configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!) (:version |0.0.1)
:modules $ [] |skir/ |lilac/
:entries $ {}
:test $ {} (:init-fn |app.test/main!) (:reload-fn |app.test/reload!)
:modules $ [] |calcit-test/
:files $ {}
|app.main $ {}
:defs $ {}
|main! $ quote
defn main! () $ skir/create-server! on-request!
{} $ :port 11029
|on-request! $ quote
defn on-request! (req res)
let
url $ get (:query req) "\"url"
if (some? url)
->
.!get axios url $ js-object ("\"maxRedirects" 0)
"\"validateStatus" $ fn (status)
and (>= status 200) (< status 500)
.!then $ fn (response) (js/console.log)
{} (:code 302) (:message |OK)
:headers $ {}
:location $ .-location (.-headers response)
:body nil
.!catch $ fn (err) (println "\"failed" err)
{} (:code 500) (:message "|Fetch failed")
:headers $ {} (:Content-Type |text/plain)
:body $ {} (:message "|Fetch Failed")
:body $ str err
{} (:code 400) (:message "\"No URL provided")
:headers $ {} (:Content-Type |text/plain)
:body $ {} (:message "\"No URL provided")
|reload! $ quote
defn reload! () $ println "\"nothing yet"
:ns $ quote
ns app.main $ :require (skir.core :as skir) ("\"axios" :default axios)