44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { Hono } from 'hono';
|
|
import { serveStatic } from 'hono/bun';
|
|
import { join } from 'path';
|
|
import { initializeTokenService, startBackgroundRefresh } from './token-service';
|
|
import { createAuthRoutes } from './auth-routes';
|
|
|
|
// PERMANENT: Initialize token service and start background refresh
|
|
// Loads existing tokens from file if available
|
|
// Starts 5-minute background refresh cycle
|
|
initializeTokenService();
|
|
startBackgroundRefresh();
|
|
|
|
// Create Hono app
|
|
const app = new Hono();
|
|
|
|
// Mount auth routes
|
|
app.route('/api/auth', createAuthRoutes());
|
|
|
|
// Health check endpoint
|
|
app.get('/health', (c) => {
|
|
return c.text('OK');
|
|
});
|
|
|
|
// Version endpoint
|
|
app.get('/version', (c) => {
|
|
return c.json({ version: '1.0.0-beta1' });
|
|
});
|
|
|
|
// PERMANENT: Serve static frontend files
|
|
// Serves from frontend/ directory
|
|
const publicDir = join(import.meta.dir, '../frontend');
|
|
app.use('/*', serveStatic({ root: publicDir }));
|
|
|
|
// Start server on port 3005
|
|
const port = 3005;
|
|
console.log(`Mode2Test (AuthAndToken) running on http://localhost:${port}`);
|
|
console.log(`Auth API: /api/auth/*`);
|
|
console.log(`SignIn page: /signin.html`);
|
|
|
|
export default {
|
|
fetch: app.fetch,
|
|
port,
|
|
};
|