Skip to content

Commit 5134bb2

Browse files
committed
feat: add 404 not found page and update catch-all handler
1 parent d6e9146 commit 5134bb2

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/client/routes/web.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'url';
44
import { DashboardController } from '../controller/dashboard.js';
55
import { MyFileController } from '../controller/my-file.js';
66
import { StarredController } from '../controller/starred.js';
7+
import { Controller } from '../controller/controller.js';
78

89
const __filename = fileURLToPath(import.meta.url);
910
const __dirname = path.dirname(__filename);
@@ -24,5 +25,15 @@ app.get('/', DashboardController.get);
2425
app.get('/files', MyFileController.get);
2526
app.get('/starred', StarredController.get);
2627

28+
// Catch-all 404 handler - render not-found page with default config
29+
app.use((req, res) => {
30+
const pageData = {
31+
...Controller.defaultConfig,
32+
page: 'not-found',
33+
title: '404 Not Found',
34+
currentPath: req.path
35+
};
36+
res.status(404).render('layouts/main', pageData);
37+
});
2738

2839
export default app;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<main class="flex-1 overflow-y-auto bg-background relative">
2+
<%- include('../components/header') %>
3+
4+
<div class="p-12 flex items-center justify-center">
5+
<div class="max-w-xl text-center">
6+
<h1 class="text-6xl font-bold text-slate-900">404</h1>
7+
<p class="mt-4 text-xl text-slate-700">Page not found</p>
8+
<p class="mt-2 text-sm text-slate-400">We couldn't find the page you're looking for.</p>
9+
<div class="mt-6">
10+
<a href="/" class="inline-block px-4 py-2 bg-primary text-white rounded-lg">Go back home</a>
11+
</div>
12+
</div>
13+
</div>
14+
</main>

0 commit comments

Comments
 (0)