Compare commits
4 Commits
feat/web-s
...
292991c605
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
292991c605 | ||
|
|
4640cd11a7 | ||
|
|
43a003f641 | ||
|
|
6f4426e49d |
36
src/web/public/script.js
Normal file
36
src/web/public/script.js
Normal file
@@ -0,0 +1,36 @@
|
||||
function formatUptime(seconds) {
|
||||
if (seconds < 0) return "0s";
|
||||
|
||||
const days = Math.floor(seconds / (3600 * 24));
|
||||
const hours = Math.floor((seconds % (3600 * 24)) / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
const secs = Math.floor(seconds % 60);
|
||||
|
||||
const parts = [];
|
||||
if (days > 0) parts.push(`${days}d`);
|
||||
if (hours > 0) parts.push(`${hours}h`);
|
||||
if (minutes > 0) parts.push(`${minutes}m`);
|
||||
parts.push(`${secs}s`);
|
||||
|
||||
return parts.join(" ");
|
||||
}
|
||||
|
||||
function updateUptime() {
|
||||
const el = document.getElementById("uptime-display");
|
||||
if (!el) return;
|
||||
|
||||
const startTimestamp = parseInt(el.getAttribute("data-start-timestamp"), 10);
|
||||
if (isNaN(startTimestamp)) return;
|
||||
|
||||
const now = Date.now();
|
||||
const elapsedSeconds = (now - startTimestamp) / 1000;
|
||||
|
||||
el.textContent = formatUptime(elapsedSeconds);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Update immediately to prevent stale content flash if possible
|
||||
updateUptime();
|
||||
// Update every second
|
||||
setInterval(updateUptime, 1000);
|
||||
});
|
||||
@@ -1,68 +1,458 @@
|
||||
:root {
|
||||
--bg-color: #0f172a;
|
||||
--text-color: #f8fafc;
|
||||
--accent-color: #38bdf8;
|
||||
--card-bg: #1e293b;
|
||||
--font-family: system-ui, -apple-system, sans-serif;
|
||||
/* Color Palette - HSL (Hue, Saturation, Lightness) */
|
||||
/* Primary (Aurora Cyan) */
|
||||
--primary-h: 180;
|
||||
--primary-s: 100%;
|
||||
--primary-l: 50%;
|
||||
--primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
|
||||
|
||||
/* Secondary (Aurora Purple) */
|
||||
--secondary-h: 270;
|
||||
--secondary-s: 100%;
|
||||
--secondary-l: 65%;
|
||||
--secondary: hsl(var(--secondary-h), var(--secondary-s), var(--secondary-l));
|
||||
|
||||
/* Backgrounds (Dark Slate) */
|
||||
--bg-h: 222;
|
||||
--bg-s: 47%;
|
||||
--bg-l: 7%;
|
||||
/* Very Dark */
|
||||
--bg-color: hsl(var(--bg-h), var(--bg-s), var(--bg-l));
|
||||
|
||||
--card-bg-h: 217;
|
||||
--card-bg-s: 33%;
|
||||
--card-bg-l: 15%;
|
||||
--card-bg: hsl(var(--card-bg-h), var(--card-bg-s), var(--card-bg-l));
|
||||
|
||||
/* Text */
|
||||
--text-main: hsl(210, 40%, 98%);
|
||||
--text-muted: hsl(215, 20%, 65%);
|
||||
--text-accent: var(--primary);
|
||||
|
||||
/* Borders */
|
||||
--border-color: hsl(215, 25%, 25%);
|
||||
|
||||
/* Typography */
|
||||
--font-heading: 'Outfit', system-ui, sans-serif;
|
||||
--font-body: 'Inter', system-ui, sans-serif;
|
||||
|
||||
/* Spacing & Radii */
|
||||
--radius-md: 0.75rem;
|
||||
--radius-lg: 1rem;
|
||||
--header-height: 4rem;
|
||||
|
||||
/* Effects */
|
||||
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
|
||||
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
||||
--shadow-glow: 0 0 15px hsla(var(--primary-h), var(--primary-s), 50%, 0.15);
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-color);
|
||||
font-family: var(--font-family);
|
||||
color: var(--text-main);
|
||||
font-family: var(--font-body);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
line-height: 1.6;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-family: var(--font-heading);
|
||||
margin-top: 0;
|
||||
line-height: 1.2;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
header {
|
||||
background-color: var(--card-bg);
|
||||
padding: 1rem 2rem;
|
||||
border-bottom: 1px solid #334155;
|
||||
background: rgba(15, 23, 42, 0.8);
|
||||
/* Semi-transparent */
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
height: var(--header-height);
|
||||
padding: 0 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
header h1 {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
color: var(--accent-color);
|
||||
margin: 0;
|
||||
background: linear-gradient(135deg, var(--primary), var(--secondary));
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
header nav a {
|
||||
color: var(--text-muted);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
margin-left: 1.5rem;
|
||||
transition: color 0.15s ease;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
header nav a:hover {
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
/* Main Layout */
|
||||
main {
|
||||
flex: 1;
|
||||
padding: 2rem;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Card Component */
|
||||
.card {
|
||||
background-color: var(--card-bg);
|
||||
border-radius: 0.5rem;
|
||||
padding: 1.5rem;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 2rem;
|
||||
margin-bottom: 1.5rem;
|
||||
box-shadow: var(--shadow-md);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: var(--shadow-glow), var(--shadow-md);
|
||||
border-color: hsla(var(--primary-h), var(--primary-s), 50%, 0.3);
|
||||
}
|
||||
|
||||
.card h2 {
|
||||
font-size: 1.25rem;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid #334155;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
color: var(--text-main);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
footer {
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
color: #94a3b8;
|
||||
font-size: 0.875rem;
|
||||
border-top: 1px solid #334155;
|
||||
.card p {
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 0;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
/* Links */
|
||||
a {
|
||||
color: var(--accent-color);
|
||||
color: var(--primary);
|
||||
text-decoration: none;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
/* Buttons (Future Proofing) */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: var(--radius-md);
|
||||
font-weight: 600;
|
||||
font-family: var(--font-heading);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
border: none;
|
||||
font-size: 0.9rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, var(--primary), hsl(var(--primary-h), 90%, 45%));
|
||||
color: #000;
|
||||
/* Contrast text on Cyan */
|
||||
box-shadow: 0 4px 6px -1px hsla(var(--primary-h), var(--primary-s), 50%, 0.2);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
filter: brightness(1.1);
|
||||
box-shadow: 0 6px 8px -1px hsla(var(--primary-h), var(--primary-s), 50%, 0.3);
|
||||
}
|
||||
|
||||
/* Forms & Inputs */
|
||||
input[type="text"],
|
||||
input[type="email"],
|
||||
input[type="password"],
|
||||
textarea,
|
||||
select {
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
background-color: rgba(15, 23, 42, 0.5);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-main);
|
||||
font-family: var(--font-body);
|
||||
font-size: 0.95rem;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
input:focus,
|
||||
textarea:focus,
|
||||
select:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 2px hsla(var(--primary-h), var(--primary-s), 50%, 0.2);
|
||||
background-color: rgba(15, 23, 42, 0.8);
|
||||
}
|
||||
|
||||
/* Tables */
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding: 1rem;
|
||||
background-color: rgba(15, 23, 42, 0.5);
|
||||
color: var(--text-muted);
|
||||
font-weight: 600;
|
||||
font-size: 0.85rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 1rem;
|
||||
border-bottom: 1px solid #1e293b;
|
||||
/* Fallback or specific border */
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
tr:hover td {
|
||||
background-color: rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
footer {
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
border-top: 1px solid var(--border-color);
|
||||
background: var(--bg-color);
|
||||
}
|
||||
|
||||
/* Utilities */
|
||||
.text-gradient {
|
||||
background: linear-gradient(135deg, var(--primary), var(--secondary));
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
/* Animations & Micro-Interactions */
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Entry Animations */
|
||||
.fade-in {
|
||||
animation: fadeIn 0.4s ease-out forwards;
|
||||
}
|
||||
|
||||
/* Stagger animations for children using nth-child */
|
||||
main>* {
|
||||
opacity: 0;
|
||||
/* Initially hidden */
|
||||
animation: slideUp 0.5s ease-out forwards;
|
||||
}
|
||||
|
||||
main>*:nth-child(1) {
|
||||
animation-delay: 0.1s;
|
||||
}
|
||||
|
||||
main>*:nth-child(2) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
main>*:nth-child(3) {
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
|
||||
main>*:nth-child(4) {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
/* Dynamic Background */
|
||||
body::before {
|
||||
content: '';
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background:
|
||||
radial-gradient(circle at 15% 50%, hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.08), transparent 25%),
|
||||
radial-gradient(circle at 85% 30%, hsla(var(--secondary-h), var(--secondary-s), var(--secondary-l), 0.08), transparent 25%);
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Link Interactions */
|
||||
a {
|
||||
position: relative;
|
||||
transition: color 0.2s ease, opacity 0.2s ease;
|
||||
}
|
||||
|
||||
header nav a::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -4px;
|
||||
left: 0;
|
||||
width: 0%;
|
||||
height: 2px;
|
||||
background: var(--primary);
|
||||
transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
header nav a:hover::after {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Accessibility: Reduced Motion */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Mobile Responsiveness */
|
||||
@media (max-width: 768px) {
|
||||
:root {
|
||||
--header-height: 3.5rem;
|
||||
/* Compact header on mobile */
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 14px;
|
||||
/* Slightly smaller base font */
|
||||
}
|
||||
|
||||
/* Layout Adjustments */
|
||||
header {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
header nav a {
|
||||
margin-left: 1rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 1rem;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* Typography Scaling */
|
||||
h1 {
|
||||
font-size: 1.75rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
/* Card Adjustments */
|
||||
.card {
|
||||
padding: 1.25rem;
|
||||
border-radius: var(--radius-md);
|
||||
/* Slightly smaller radius */
|
||||
}
|
||||
|
||||
/* Stack flex containers if needed (general util) */
|
||||
.flex-col-mobile {
|
||||
flex-direction: column !important;
|
||||
}
|
||||
|
||||
/* Touch Targets */
|
||||
.btn,
|
||||
a,
|
||||
input,
|
||||
select {
|
||||
min-height: 44px;
|
||||
/* Compliance with touch target guidelines */
|
||||
}
|
||||
|
||||
/* Horizontal scroll for wide tables */
|
||||
.table-container {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
margin-left: -1rem;
|
||||
margin-right: -1rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
import { BaseLayout } from "../views/layout";
|
||||
import { formatUptime } from "../utils/format";
|
||||
|
||||
export function homeRoute(): Response {
|
||||
const uptime = formatUptime(process.uptime());
|
||||
const startTimestamp = Date.now() - (process.uptime() * 1000);
|
||||
|
||||
const content = `
|
||||
<div class="card">
|
||||
<h2>Welcome</h2>
|
||||
@@ -9,6 +13,7 @@ export function homeRoute(): Response {
|
||||
<div class="card">
|
||||
<h3>Status</h3>
|
||||
<p>System operational.</p>
|
||||
<p><strong>Uptime:</strong> <span id="uptime-display" data-start-timestamp="${Math.floor(startTimestamp)}">${uptime}</span></p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
24
src/web/utils/format.test.ts
Normal file
24
src/web/utils/format.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { formatUptime } from "./format";
|
||||
|
||||
describe("formatUptime", () => {
|
||||
it("formats seconds correctly", () => {
|
||||
expect(formatUptime(45)).toBe("45s");
|
||||
});
|
||||
|
||||
it("formats minutes and seconds", () => {
|
||||
expect(formatUptime(65)).toBe("1m 5s");
|
||||
});
|
||||
|
||||
it("formats hours, minutes, and seconds", () => {
|
||||
expect(formatUptime(3665)).toBe("1h 1m 5s");
|
||||
});
|
||||
|
||||
it("formats days correctly", () => {
|
||||
expect(formatUptime(90061)).toBe("1d 1h 1m 1s");
|
||||
});
|
||||
|
||||
it("handles zero", () => {
|
||||
expect(formatUptime(0)).toBe("0s");
|
||||
});
|
||||
});
|
||||
20
src/web/utils/format.ts
Normal file
20
src/web/utils/format.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Formats a duration in seconds into a human-readable string.
|
||||
* Example: 3665 -> "1h 1m 5s"
|
||||
*/
|
||||
export function formatUptime(seconds: number): string {
|
||||
if (seconds < 0) return "0s";
|
||||
|
||||
const days = Math.floor(seconds / (3600 * 24));
|
||||
const hours = Math.floor((seconds % (3600 * 24)) / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
const secs = Math.floor(seconds % 60);
|
||||
|
||||
const parts = [];
|
||||
if (days > 0) parts.push(`${days}d`);
|
||||
if (hours > 0) parts.push(`${hours}h`);
|
||||
if (minutes > 0) parts.push(`${minutes}m`);
|
||||
parts.push(`${secs}s`);
|
||||
|
||||
return parts.join(" ");
|
||||
}
|
||||
@@ -15,6 +15,9 @@ export function BaseLayout({ title, content }: LayoutProps): string {
|
||||
<title>${safeTitle} | Aurora</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<meta name="description" content="Aurora Bot Web Interface">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Outfit:wght@500;600;700&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@@ -29,6 +32,7 @@ export function BaseLayout({ title, content }: LayoutProps): string {
|
||||
<footer>
|
||||
<p>© ${new Date().getFullYear()} Aurora Bot</p>
|
||||
</footer>
|
||||
<script src="/script.js" defer></script>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
# 2026-01-07-web-server-foundation: Web Server Infrastructure Foundation
|
||||
|
||||
**Status:** Done
|
||||
**Created:** 2026-01-07
|
||||
**Tags:** infrastructure, web, core
|
||||
|
||||
## 1. Context & User Story
|
||||
* **As a:** Developer
|
||||
* **I want to:** Establish a lightweight, integrated web server foundation within the existing codebase.
|
||||
* **So that:** We can serve internal tools (Workbench) or public pages (Leaderboard) with minimal friction, avoiding complex separate build pipelines.
|
||||
|
||||
## 2. Technical Requirements
|
||||
### Architecture
|
||||
- **Native Bun Server:** Use `Bun.serve()` for high performance.
|
||||
- **Exposure:** The server port must be exposed in `docker-compose.yml` to be accessible outside the container.
|
||||
- **Rendering Strategy:** **Server-Side Rendering (SSR) via Template Literals**.
|
||||
- *Why?* Zero dependencies. No build step (like Vite/Webpack) required. We can simply write functions that return HTML strings.
|
||||
- *Client Side:* Minimal Vanilla JS or a lightweight drop-in library (like HTMX or Alpine from CDN) can be used if interactivity is needed later.
|
||||
|
||||
### File Organization (`src/web/`)
|
||||
We will separate the web infrastructure from game modules to keep concerns clean.
|
||||
- `src/web/server.ts`: Main server class/entry point.
|
||||
- `src/web/router.ts`: Simple routing logic.
|
||||
- `src/web/routes/`: Individual route handlers (e.g., `home.ts`, `health.ts`).
|
||||
- `src/web/views/`: Reusable HTML template functions (Header, Footer, Layouts).
|
||||
- `src/web/public/`: Static assets (CSS, Images) served directly.
|
||||
|
||||
### API / Interface
|
||||
- **GET /health**: Returns `{ status: "ok", uptime: <seconds> }`.
|
||||
- **GET /**: Renders a basic HTML landing page using the View system.
|
||||
|
||||
## 3. Constraints & Validations (CRITICAL)
|
||||
- **Zero Frameworks:** No Express/NestJS.
|
||||
- **Zero Build Tools:** No Webpack/Vite. The code must be runnable directly by `bun run`.
|
||||
- **Docker Integration:** Port 3000 (or env `PORT`) must be mapped in Docker Compose.
|
||||
- **Static Files:** Must implement a handler to check `src/web/public` for file requests.
|
||||
|
||||
## 4. Acceptance Criteria
|
||||
1. [x] `docker-compose up` exposes port 3000.
|
||||
2. [x] `http://localhost:3000` loads a styled HTML page (verifying static asset serving + SSR).
|
||||
3. [x] `http://localhost:3000/health` returns JSON.
|
||||
4. [x] Folder structure established as defined above.
|
||||
|
||||
## 5. Implementation Plan
|
||||
- [x] **Infrastructure**: Create `src/web/` directory structure.
|
||||
- [x] **Core Logic**: Implement `WebServer` class in `src/web/server.ts` with routing and static file serving logic.
|
||||
- [x] **Integration**: Bind `WebServer.start()` to `src/index.ts`.
|
||||
- [x] **Docker**: Update `docker-compose.yml` to map port `3000:3000`.
|
||||
- [x] **Views**: Create a basic `BaseLayout` function in `src/web/views/layout.ts`.
|
||||
- [x] **Env**: Add `PORT` to `config.ts` / `env.ts`.
|
||||
|
||||
## Implementation Notes
|
||||
- Created `src/web` directory with `router.ts`, `server.ts` and subdirectories `routes`, `views`, `public`.
|
||||
- Implemented `WebServer` class using `Bun.serve`.
|
||||
- Added basic CSS and layout system.
|
||||
- Added `PORT` to `src/lib/env.ts` (default 3000).
|
||||
- Integrated into `src/index.ts` to start on boot and graceful shutdown.
|
||||
- Fixed unrelated typing issues in `src/commands/admin/note.ts` and `src/db/indexes.test.ts` to pass strict CI checks.
|
||||
- Verified with `bun test` and `bun x tsc`.
|
||||
Reference in New Issue
Block a user