Skip to content

Commit

Permalink
cleaner error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadjung committed Aug 20, 2024
1 parent 6fe0641 commit 13c62a2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
8 changes: 2 additions & 6 deletions src/clientApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,8 @@ koa.use(async (ctx, next) => {
koa.use(async (context, next) => {
if (['/', 'index.html'].includes(context.path)) {
const communityPages = getCommunityPages();
const serverList = await getServerListConfig(__dirname, hostAddress, port, argv.server_list);
if (serverList.length) {
await context.render(indexFile, { serverList, communityPages });
return;
}
await context.render(indexFile, { communityPages });
let serverList = await getServerListConfig(__dirname, hostAddress, port, argv.server_list);
await context.render(indexFile, { serverList, communityPages });
}

return next();
Expand Down
75 changes: 41 additions & 34 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,51 @@
<main>
<div class="card">
<% // The serverList is passed in from the clientApp %>
<% serverList.forEach(section=> { %>
<div class="card-section" data-section="<%= section.name %>">
<% if (section.name.toLowerCase()==='official' ) { %>
<div class="screeps-logo">
<img src="<%= section.logo %>" alt="Screeps Logo" />
<% if(serverList.length===0){ %>
<h1> Could not load Server List</h1>
<% } %>
<% serverList.forEach(section=> { %>
<div class="card-section" data-section="<%= section.name %>">
<% if (section.name.toLowerCase()==='official' ) { %>
<div class="screeps-logo">
<img src="<%= section.logo %>" alt="Screeps Logo" />
</div>
<% } else { %>
<h2>
<%= section.name %>
</h2>
<% } %>
<% section.servers.forEach(server=> { %>
<div class="server">
<a href="<%= server.url %>">
<button>
<%= server.name %>
</button>
</a>
<span class="status-circle" data-api="<%= server.api %>"></span>
</div>
<% }) %>
</div>
<% } else { %>
<h2>
<%= section.name %>
</h2>
<% } %>
<% section.servers.forEach(server=> { %>
<div class="server">
<a href="<%= server.url %>">
<button>
<%= server.name %>
</button>
</a>
<span class="status-circle" data-api="<%= server.api %>"></span>
</div>
<% }) %>
</div>
<% }) %>
<% }) %>
</div>
<div class="card community-card">
<h2>Community Content</h2>
<div class="comm-container">
<% communityPages.forEach(page=> { %>
<div class="comm-page">
<a href="<%= page.url %> " target="_blank" rel="noopener noreferrer">
<button class="comm-page-buttom">
<%= page.title %>
</button>
</a>
</div>
<% }) %>
<% if(communityPages.length===0){ %>
<h1> Could not load Community Content</h1>
<% } else{ %>
<h2>Community Content</h2>
<% } %>
<div class="comm-container">
<% communityPages.forEach(page=> { %>
<div class="comm-page">
<a href="<%= page.url %> " target="_blank" rel="noopener noreferrer">
<button class="comm-page-buttom">
<%= page.title %>
</button>
</a>
</div>
<% }) %>

</div>
</div>
</div>
</main>
<script src="/dist/serverStatus.js"></script>
Expand Down

0 comments on commit 13c62a2

Please sign in to comment.