41 lines
1 KiB
Gleam
41 lines
1 KiB
Gleam
import gleam/erlang/process
|
|
import mist
|
|
import wisp
|
|
import bowie/router
|
|
import bowie/web.{Context, Env}
|
|
import envoy
|
|
import sqlight
|
|
|
|
pub fn main() {
|
|
wisp.configure_logger()
|
|
let secret_key_base = wisp.random_string(64)
|
|
|
|
let assert Ok(admin_token) = envoy.get("ADMIN_TOKEN")
|
|
let assert Ok(annual_link) = envoy.get("ANNUAL_LINK")
|
|
let assert Ok(monthly_link) = envoy.get("MONTHLY_LINK")
|
|
let assert Ok(forgejo_url) = envoy.get("FORGEJO_URL")
|
|
let assert Ok(stripe_token) = envoy.get("STRIPE_TOKEN")
|
|
let assert Ok(database_file) = envoy.get("DATABASE_FILE")
|
|
|
|
use db <- sqlight.with_connection(database_file)
|
|
|
|
let context =
|
|
Context(
|
|
db: db,
|
|
env: Env(
|
|
annual_link: annual_link,
|
|
monthly_link: monthly_link,
|
|
forgejo_url: forgejo_url,
|
|
stripe_token: stripe_token,
|
|
admin_token: admin_token,
|
|
),
|
|
)
|
|
|
|
let assert Ok(_) =
|
|
wisp.mist_handler(router.handle_request(_, context), secret_key_base)
|
|
|> mist.new
|
|
|> mist.port(8000)
|
|
|> mist.start_http
|
|
|
|
process.sleep_forever()
|
|
}
|