Clean up: remove dead code and fix broken file references
This commit is contained in:
@@ -3,26 +3,6 @@ import { serveStatic } from 'hono/bun';
|
||||
import { cors } from 'hono/cors';
|
||||
import PocketBase from 'pocketbase';
|
||||
import { ConfidentialClientApplication } from '@azure/msal-node';
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
// Load env from Estimator/.env
|
||||
const envPath = join(import.meta.dir, 'Estimator', '.env');
|
||||
try {
|
||||
const envContent = readFileSync(envPath, 'utf-8');
|
||||
envContent.split('\n').forEach(line => {
|
||||
const trimmed = line.trim();
|
||||
if (trimmed && !trimmed.startsWith('#')) {
|
||||
const [key, ...valueParts] = trimmed.split('=');
|
||||
if (key && valueParts.length > 0) {
|
||||
process.env[key.trim()] = valueParts.join('=').trim();
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log('✓ Loaded env from Estimator/.env');
|
||||
} catch (e) {
|
||||
console.warn('⚠ Could not load Estimator/.env:', (e as Error).message);
|
||||
}
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
@@ -101,7 +81,7 @@ app.post('/api/submit', async (c) => {
|
||||
|
||||
// Serve static files
|
||||
app.get('/', async (c) => {
|
||||
const html = await Bun.file('index.html').text();
|
||||
const html = await Bun.file('estimatortable.html').text();
|
||||
return c.html(html);
|
||||
});
|
||||
|
||||
@@ -110,11 +90,6 @@ app.get('/estimatortable.html', async (c) => {
|
||||
return c.html(html);
|
||||
});
|
||||
|
||||
app.get('/admin.html', async (c) => {
|
||||
const html = await Bun.file('admin.html').text();
|
||||
return c.html(html);
|
||||
});
|
||||
|
||||
app.get('/appsettings.html', async (c) => {
|
||||
const html = await Bun.file('appsettings.html').text();
|
||||
return c.html(html);
|
||||
@@ -387,12 +362,6 @@ app.get('/api/records', async (c) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Serve admin.html
|
||||
app.get('/admin', async (c) => {
|
||||
const html = await Bun.file(new URL('./admin.html', import.meta.url)).text();
|
||||
return c.html(html);
|
||||
});
|
||||
|
||||
// Export collection schema and headers (requires superuser token)
|
||||
app.get('/api/export/schema', async (c) => {
|
||||
try {
|
||||
@@ -498,9 +467,8 @@ app.get('/api/export/schema', async (c) => {
|
||||
const PORT = Number(process.env.PORT || 6500);
|
||||
|
||||
console.log(`\n🚀 Server running on port ${PORT}`);
|
||||
console.log(`\n📊 Estimator Table: \x1b[36mhttp://localhost:${PORT}/estimatortable.html\x1b[0m`);
|
||||
console.log(`📝 Idea & Feedback Form: \x1b[36mhttp://localhost:${PORT}/index.html\x1b[0m`);
|
||||
console.log(`👤 Admin Panel: \x1b[36mhttp://localhost:${PORT}/admin.html\x1b[0m\n`);
|
||||
console.log(`📊 Estimator Table: \x1b[36mhttp://localhost:${PORT}/\x1b[0m`);
|
||||
console.log(`⚙️ Settings: \x1b[36mhttp://localhost:${PORT}/appsettings.html\x1b[0m\n`);
|
||||
|
||||
export default {
|
||||
port: PORT,
|
||||
|
||||
Reference in New Issue
Block a user