Only minifies playground in production mode
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Dominic Grimm 2022-02-06 21:02:55 +01:00
parent 6cbfd285d8
commit 44833fff59

View file

@ -7,7 +7,15 @@ module Backend
class WebServer
include Router
GRAPHQL_PLAYGROUND = {{ run("./macros/minify_html.cr", read_file("#{__DIR__}/playground.html")).stringify }}
GRAPHQL_PLAYGROUND = {{ flag?(:development) ? read_file("#{__DIR__}/playground.html") : run("./macros/minify_html.cr", read_file("#{__DIR__}/playground.html")).stringify }}
struct GraphQLQueryData
include JSON::Serializable
property query : String
property variables : Hash(String, JSON::Any)?
property operation_name : String?
end
def draw_routes : Nil
# enable graphql playground when in development mode or explicitly enabled
@ -16,7 +24,7 @@ module Backend
get "/" do |context|
context.response.content_type = "text/html"
context.response.print(GRAPHQL_PLAYGROUND)
context.response.puts(GRAPHQL_PLAYGROUND)
context
end
@ -53,14 +61,6 @@ module Backend
server.bind_tcp("0.0.0.0", 80, true)
server.listen
end
private struct GraphQLQueryData
include JSON::Serializable
property query : String
property variables : Hash(String, JSON::Any)?
property operation_name : String?
end
end
end
end