Add embedded Express admin API and unified dev workflow.

Move admin backend into this repo (Express + MySQL on :8085) so npm run dev starts both API and Vite, with updated env defaults and Caddy config for gadm.tkmind.cn.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
John
2026-06-16 16:29:06 -07:00
parent 680e2c9427
commit 9ecfa73831
13 changed files with 1702 additions and 45 deletions
+24
View File
@@ -0,0 +1,24 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const projectRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
export function loadProjectEnv() {
for (const file of ['.env', '.env.local']) {
const filePath = path.join(projectRoot, file);
if (!fs.existsSync(filePath)) continue;
for (const line of fs.readFileSync(filePath, 'utf8').split('\n')) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) continue;
const eq = trimmed.indexOf('=');
if (eq < 0) continue;
const key = trimmed.slice(0, eq).trim();
const value = trimmed.slice(eq + 1).trim();
if (!process.env[key]) process.env[key] = value;
}
}
return projectRoot;
}
export { projectRoot };