Simplified HTML minification for GraphQL playground macro statement
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dominic Grimm 2022-02-25 12:27:25 +01:00
parent fc3b323a5d
commit 4272ceb5ac
2 changed files with 8 additions and 4 deletions

View file

@ -26,7 +26,9 @@ module Backend
# Runs API service # Runs API service
def run(_unit : ::Service::Unit) : ::Service::Unit? def run(_unit : ::Service::Unit) : ::Service::Unit?
Log.info { "Starting Api service..." } Log.info { "Starting Api service..." }
WebServer.new.run server = WebServer.new
server.draw_routes
server.run
Log.info { "Api service stopped." } Log.info { "Api service stopped." }
::Service::Unit.new(self) ::Service::Unit.new(self)

View file

@ -27,7 +27,11 @@ module Backend
# GraphQL playground HTML code # GraphQL playground HTML code
# #
# NOTE: Is minified in production # NOTE: Is minified in production
GRAPHQL_PLAYGROUND = {{ flag?(:development) ? read_file("#{__DIR__}/playground.html") : run("./macros/minify_html.cr", read_file("#{__DIR__}/playground.html")).stringify }} GRAPHQL_PLAYGROUND = {% if flag?(:development) %}
{{ read_file("#{__DIR__}/playground.html") }}
{% else %}
{{ run("./macros/minify_html.cr", read_file("#{__DIR__}/playground.html")).stringify }}
{% end %}
# GraphQL request data serializer # GraphQL request data serializer
struct GraphQLQueryData struct GraphQLQueryData
@ -80,8 +84,6 @@ module Backend
# Runs the webserver with according middleware # Runs the webserver with according middleware
def run : Nil def run : Nil
draw_routes
server = HTTP::Server.new([ server = HTTP::Server.new([
HTTP::LogHandler.new, HTTP::LogHandler.new,
HTTP::ErrorHandler.new, HTTP::ErrorHandler.new,