@@ -6,6 +6,9 @@ import uploadRoute from './routes/upload-route';
66import serveRoute from './routes/serve-route' ;
77import filesRoute from './routes/files-route' ;
88import usageRoute from './routes/usage-route' ;
9+ import oauthRoute from './routes/oauth-route' ;
10+ import dashboardApiRoute from './routes/dashboard-api-route' ;
11+ import webRoute from './routes/web-route' ;
912import { cleanupExpiredFiles } from './cron/cleanup-expired-files' ;
1013
1114const app = new Hono < { Bindings : Env } > ( ) ;
@@ -17,7 +20,16 @@ app.use('*', cors());
1720
1821app . get ( '/health' , ( c ) => c . json ( { status : 'ok' , ts : new Date ( ) . toISOString ( ) } ) ) ;
1922
20- // --- Protected routes (auth required) — registered BEFORE serve wildcard ---
23+ // Web pages (login, dashboard, root) — single-segment paths, no conflict with serve wildcard
24+ app . route ( '/' , webRoute ) ;
25+
26+ // GitHub OAuth flow (public)
27+ app . route ( '/' , oauthRoute ) ;
28+
29+ // Dashboard API (session-gated inside the route handlers)
30+ app . route ( '/' , dashboardApiRoute ) ;
31+
32+ // --- Protected file API (Bearer token) — registered BEFORE serve wildcard ---
2133
2234app . use ( '/upload' , authMiddleware ) ;
2335app . route ( '/' , uploadRoute ) ;
@@ -33,9 +45,6 @@ app.route('/', serveRoute);
3345
3446// DELETE /:id — auth applied inline to avoid conflicting with serve route
3547app . delete ( '/:id' , authMiddleware , async ( c ) => {
36- // Delegate to filesRoute handler by re-using its logic inline
37- // (Hono sub-app DELETE handler is already defined in filesRoute but registering
38- // it here ensures auth middleware fires before the wildcard serve GET)
3948 const { id } = c . req . param ( ) ;
4049 const db = c . env . D1_DATABASE ;
4150
0 commit comments