๐Ÿ‘ฉโ€๐Ÿš’ Firefighters API written in Gleam!
lustre gleam

:sparkle: handle `/`

kacaii.dev 71ba4e9c 9a6de528

verified
+32 -1
+8
.env.example
··· 1 + # ๎ฎ DATABASE 2 + export POSTGRES_USER="" 3 + export POSTGRES_PASSWORD="" 4 + export POSTGRES_DB="" 5 + export DATABASE_URL="postgresql://user:password@host:port/database" 6 + 7 + # ๎ฎ KEY 8 + export SECRET_KEY=""
+1
server/gleam.toml
··· 12 12 gleam_otp = ">= 1.2.0 and < 2.0.0" 13 13 gleam_erlang = ">= 1.3.0 and < 2.0.0" 14 14 filepath = ">= 1.1.2 and < 2.0.0" 15 + lustre = ">= 5.5.2 and < 6.0.0" 15 16 16 17 [dev-dependencies] 17 18 gleeunit = ">= 1.0.0 and < 2.0.0"
+2
server/manifest.toml
··· 29 29 { name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" }, 30 30 { name = "justin", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "justin", source = "hex", outer_checksum = "7FA0C6DB78640C6DC5FBFD59BF3456009F3F8B485BF6825E97E1EB44E9A1E2CD" }, 31 31 { name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" }, 32 + { name = "lustre", version = "5.5.2", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib", "houdini"], otp_app = "lustre", source = "hex", outer_checksum = "2DC2973D81C12E63251B636773217B8E09C5C84590A729750F6BCF009420B38E" }, 32 33 { name = "marceau", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "2D1C27504BEF45005F5DFB18591F8610FB4BFA91744878210BDC464412EC44E9" }, 33 34 { name = "mist", version = "5.0.4", build_tools = ["gleam"], requirements = ["exception", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gleam_yielder", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "7CED4B2D81FD547ADB093D97B9928B9419A7F58B8562A30A6CC17A252B31AD05" }, 34 35 { name = "mug", version = "3.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "mug", source = "hex", outer_checksum = "C01279D98E40371DA23461774B63F0E3581B8F1396049D881B0C7EB32799D93F" }, ··· 57 58 gleam_otp = { version = ">= 1.2.0 and < 2.0.0" } 58 59 gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 59 60 gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 61 + lustre = { version = ">= 5.5.2 and < 6.0.0" } 60 62 mist = { version = ">= 5.0.4 and < 6.0.0" } 61 63 pog = { version = ">= 4.1.0 and < 5.0.0" } 62 64 shared = { path = "../shared" }
+2 -1
server/src/server/router.gleam
··· 1 1 import server/context.{type Context} 2 + import server/router/home 2 3 import wisp.{type Request, type Response} 3 4 4 5 pub fn handle_request(req: Request, ctx: Context) -> Response { 5 6 use req <- middleware(req, ctx) 6 7 7 8 case wisp.path_segments(req) { 8 - [] -> wisp.ok() 9 + [] -> home.handle_request(req, ctx) 9 10 _ -> wisp.not_found() 10 11 } 11 12 }
+19
server/src/server/router/home.gleam
··· 1 + import lustre/attribute as attr 2 + import lustre/element 3 + import lustre/element/html 4 + import server/context.{type Context} 5 + import wisp.{type Request, type Response} 6 + 7 + pub fn handle_request(_req: Request, _ctx: Context) -> Response { 8 + let html_head = 9 + html.head([], [ 10 + html.title([], "SIGO"), 11 + html.script([attr.type_("module"), attr.src("/static/client.min.js")], ""), 12 + ]) 13 + 14 + let html_body = html.body([], [html.div([attr.id("app")], [])]) 15 + 16 + html.html([], [html_head, html_body]) 17 + |> element.to_document_string() 18 + |> wisp.html_response(200) 19 + }