Update port to 3030 and configure dotenv for centralized secrets

This commit is contained in:
2025-12-31 04:38:45 +00:00
parent da23cc8e3a
commit fc155cac76
4 changed files with 6 additions and 37 deletions
+4 -20
View File
@@ -1,28 +1,12 @@
import { config } from 'dotenv';
import { Hono } from 'hono';
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 local .env
const envPath = join(import.meta.dir, '.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 .env');
} catch (e) {
console.warn('⚠ Could not load .env:', (e as Error).message);
}
// Load secrets from absolute path (not in project directory)
config({ path: '/home/admin/secrets/.env' });
const app = new Hono();
@@ -126,7 +110,7 @@ app.get('/', async (c) => {
return c.html(html);
});
const PORT = Number(process.env.PORT || 5500);
const PORT = Number(process.env.PORT || 3030);
// Start Bun server manually to avoid Bun's auto startup banner
const server = Bun.serve({