2021-07-24 21:17:10 +00:00
|
|
|
require "kemal"
|
|
|
|
require "log"
|
|
|
|
require "./utils/config"
|
|
|
|
require "./endpoints/user"
|
|
|
|
|
|
|
|
if !Config.is_loaded
|
|
|
|
puts "loading config"
|
|
|
|
Config.load_config
|
|
|
|
end
|
|
|
|
|
|
|
|
serve_static false
|
|
|
|
|
|
|
|
# replacement for the expressjs/sequelize backend of todo.
|
|
|
|
# because javascript sucks.
|
2021-07-10 03:03:57 +00:00
|
|
|
module Backend
|
2021-07-24 21:17:10 +00:00
|
|
|
VERSION = "0.0.1"
|
|
|
|
end
|
|
|
|
|
|
|
|
get "/api/hello" do
|
|
|
|
"Hello"
|
|
|
|
end
|
|
|
|
|
|
|
|
# this is a slightly less hilarious way to get the integer value of something
|
|
|
|
# because now i am using JSON::Any. but i am going to keep this comment
|
|
|
|
# because i want to.
|
|
|
|
port = Config.get_config_value("port")
|
|
|
|
port_to_use = port.is_a?(JSON::Any) ? port.as_i : 8000
|
2021-07-10 03:03:57 +00:00
|
|
|
|
2021-07-24 21:17:10 +00:00
|
|
|
Kemal.run do |config|
|
|
|
|
server = config.server.not_nil!
|
|
|
|
server.bind_tcp "0.0.0.0", port_to_use
|
2021-07-10 03:03:57 +00:00
|
|
|
end
|