this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 48 lines 1.3 kB view raw
1import envoy 2import filepath as path 3import gleam/erlang/process 4import gleam/result 5import pog 6import server/context.{Context} 7import server/router 8import server/supervision_tree 9import wisp 10 11pub fn main() -> Nil { 12 wisp.configure_logger() 13 14 let db_process_name = process.new_name("db_conn") 15 let db = pog.named_connection(db_process_name) 16 17 let assert Ok(static_directory) = static_directory() 18 let assert Ok(secret_key) = envoy.get("SECRET_KEY") 19 let assert Ok(pog_config) = read_connection_url(db_process_name) 20 21 let ctx = Context(db:, static_directory:, secret_key:) 22 let handler = router.handle_request(_, ctx) 23 24 let assert Ok(_) = supervision_tree.init(pog_config, handler, secret_key) 25 26 // All done! 27 process.sleep_forever() 28} 29 30/// Reads the postgres connection string from the environment 31/// 32/// ## Example 33/// 34/// ```sh 35/// DATABASE_URL="postgresql://user:password@host:port/database" 36/// ``` 37pub fn read_connection_url( 38 name: process.Name(pog.Message), 39) -> Result(pog.Config, Nil) { 40 use config <- result.try(envoy.get("DATABASE_URL")) 41 pog.url_config(name, config) 42} 43 44/// Path to the application priv directory 45pub fn static_directory() -> Result(String, Nil) { 46 use priv <- result.map(wisp.priv_directory("server")) 47 path.join(priv, "static") 48}