todo/backend/src/backend.cr

33 lines
703 B
Crystal

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.
module Backend
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
Kemal.run do |config|
server = config.server.not_nil!
server.bind_tcp "0.0.0.0", port_to_use
end