···11+@_default:
22+ just --list
33+44+# Build CSS and JS runtime
55+build:
66+ gleam run -m lustre/dev build
+9
justfile
···11+mod client
22+mod server
33+mod shared
44+55+set quiet
66+77+# List available recipes
88+_default:
99+ just --list
+3
server/gleam.toml
···1818wisp = ">= 2.2.2 and < 3.0.0"
1919mist = ">= 6.0.3 and < 7.0.0"
2020gleam_otp = ">= 1.2.0 and < 2.0.0"
2121+gleam_erlang = ">= 1.3.0 and < 2.0.0"
2222+filepath = ">= 1.1.2 and < 2.0.0"
2323+envoy = ">= 1.2.0 and < 2.0.0"
21242225[dev_dependencies]
2326gleeunit = ">= 1.0.0 and < 2.0.0"
+3
server/manifest.toml
···2727]
28282929[requirements]
3030+envoy = { version = ">= 1.2.0 and < 2.0.0" }
3131+filepath = { version = ">= 1.1.2 and < 2.0.0" }
3232+gleam_erlang = { version = ">= 1.3.0 and < 2.0.0" }
3033gleam_otp = { version = ">= 1.2.0 and < 2.0.0" }
3134gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
3235gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
+24-2
server/src/server.gleam
···11-import gleam/io
11+import envoy
22+import filepath as path
33+import gleam/erlang/process
44+import gleam/result
55+import server/context.{Context}
66+import server/router
77+import server/supervision_tree
88+import wisp
29310pub fn main() -> Nil {
44- io.println("Hello from server!")
1111+ wisp.configure_logger()
1212+1313+ let assert Ok(static_directory) = static_directory()
1414+ let assert Ok(secret_key) = envoy.get("SECRET_KEY")
1515+1616+ let ctx = Context(static_directory:, secret_key:)
1717+ let handler = router.handle_request(_, ctx)
1818+ let assert Ok(_) = supervision_tree.start(handler, secret_key)
1919+2020+ process.sleep_forever()
2121+}
2222+2323+/// Path to the application priv directory
2424+pub fn static_directory() -> Result(String, Nil) {
2525+ use priv <- result.map(wisp.priv_directory("server"))
2626+ path.join(priv, "static")
527}
+8
server/src/server/context.gleam
···11+pub type Context {
22+ Context(
33+ /// Path to the application's priv directory
44+ static_directory: String,
55+ /// Secret used for hashing cookies and passwords
66+ secret_key: String,
77+ )
88+}