From 8d2def360ee0ec00020e9b5c1851da4a271de474 Mon Sep 17 00:00:00 2001 From: robojerk Date: Fri, 31 Oct 2025 13:28:38 -0700 Subject: [PATCH] Extract YAML validation to separate module - Created yaml-validator.js with pure validation functions - Removed redundant checkYAMLFormatting function (rely on js-yaml) - Fixed function shadowing issues by using window._validateYAMLPure - Updated nginx config to serve JS files with correct MIME type - Improved error reporting with line/column numbers from js-yaml --- Dockerfile | 12 +++- docker-compose.yml | 1 + index.html | 167 +++++++++++++++------------------------------ yaml-validator.js | 137 +++++++++++++++++++++++++++++++++++++ 4 files changed, 201 insertions(+), 116 deletions(-) create mode 100644 yaml-validator.js diff --git a/Dockerfile b/Dockerfile index c06359b..f3fa1d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN pip install --no-cache-dir -r backend/requirements.txt COPY backend/ /app/backend/ # Copy frontend files -COPY index.html manage.html /usr/share/nginx/html/ +COPY index.html manage.html yaml-validator.js /usr/share/nginx/html/ # Configure nginx RUN echo 'server {\n\ @@ -27,8 +27,10 @@ RUN echo 'server {\n\ root /usr/share/nginx/html;\n\ index index.html;\n\ \n\ - location / {\n\ - try_files $uri $uri/ /index.html;\n\ + # Serve JavaScript files with correct MIME type (must come before location /)\n\ + location ~* \\.js$ {\n\ + default_type application/javascript;\n\ + try_files $uri =404;\n\ }\n\ \n\ location /api {\n\ @@ -36,6 +38,10 @@ RUN echo 'server {\n\ proxy_set_header Host $host;\n\ proxy_set_header X-Real-IP $remote_addr;\n\ }\n\ + \n\ + location / {\n\ + try_files $uri $uri/ /index.html;\n\ + }\n\ }' > /etc/nginx/sites-available/default # Configure supervisor diff --git a/docker-compose.yml b/docker-compose.yml index bc1f59f..1463917 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ services: # Hot reload frontend (optional, for development) - ./index.html:/usr/share/nginx/html/index.html:ro,z - ./manage.html:/usr/share/nginx/html/manage.html:ro,z + - ./yaml-validator.js:/usr/share/nginx/html/yaml-validator.js:ro,z environment: # Set working directory for database - PWD=/app/data diff --git a/index.html b/index.html index 59a77d7..3cedc93 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,7 @@ Stronghold - Minecraft Server Generator +