aboutsummaryrefslogtreecommitdiff
path: root/src/mayu.gleam
blob: 69e14742036b86a64ede984af1deda4b1dd5f13f (plain) (blame)
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
import database
import gleam/erlang/process
import mist
import request
import simplifile
import sqlight
import wisp

pub fn main() {
  wisp.configure_logger()

  let _ = simplifile.create_directory("./data")

  use connection <- sqlight.with_connection("./data/mayu.sqlite3")

  database.setup(connection)

  let secret_key_base = wisp.random_string(64)
  let assert Ok(_) =
    wisp.mist_handler(
      fn(request) { request.handle(request, connection) },
      secret_key_base,
    )
    |> mist.new
    |> mist.port(8080)
    |> mist.start_http

  process.sleep_forever()
}