From fc155cac76565f8b20c0de305f9fb7482c434a62 Mon Sep 17 00:00:00 2001 From: aewing Date: Wed, 31 Dec 2025 04:38:45 +0000 Subject: [PATCH] Update port to 3030 and configure dotenv for centralized secrets --- .env | 16 ---------------- .gitignore | 1 + package.json | 2 +- server.ts | 24 ++++-------------------- 4 files changed, 6 insertions(+), 37 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 8d236b1..0000000 --- a/.env +++ /dev/null @@ -1,16 +0,0 @@ -# Microsoft Azure AD Configuration -CLIENT_SECRET=7aD8Q~d5K~_PzQv6KqDdrEnmyXHE60eVDpbcnaK_ -TENANT_ID=3fd97ea7-b124-41f1-855f-52d8ac3b16c7 -CLIENT_ID=3c846e71-9609-40e1-b458-0eb805e21b9f -REDIRECT_URI=https://pocketbase.ccllc.pro/api/oauth2-redirect - -# PocketBase Configuration -PB_DB=https://pocketbase.ccllc.pro -PB_AUTH_COLLECTION=Users - -#PocketBase Tables -PB_Job_Collection=Job_Info_TestEnv -PB_Notes_Collection=Notes -PB_App_Preferences_Collection=app_preferences_settings -PB_User_Preferences_Collection=user_preferences_settings -PB_Attachments_Collection=Attachments diff --git a/.gitignore b/.gitignore index d2d05a8..b3c4ef1 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ Thumbs.db # Bun/NPM cache artifacts bun.lock npm-debug.log* +.env diff --git a/package.json b/package.json index ffa819d..de3a3ed 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Prism Notes: PocketBase + Microsoft Graph OAuth capture app", "type": "module", "scripts": { - "dev": "bun run --watch server.ts", + "dev": "PORT=3030 bun run --watch server.ts", "start": "bun run server.ts" }, "dependencies": { diff --git a/server.ts b/server.ts index ab7e89c..434003b 100644 --- a/server.ts +++ b/server.ts @@ -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({