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
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env node
import { spawn } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
function spawnChild(command, args, label) {
const child = spawn(command, args, {
cwd: root,
stdio: 'inherit',
env: process.env,
});
child.on('exit', (code, signal) => {
if (signal) return;
if (code && code !== 0) shutdown(code ?? 1);
});
return child;
}
let server;
let web;
let stopping = false;
function shutdown(code = 0) {
if (stopping) return;
stopping = true;
server?.kill('SIGTERM');
web?.kill('SIGTERM');
setTimeout(() => process.exit(code), 200).unref();
}
process.on('SIGINT', () => shutdown(0));
process.on('SIGTERM', () => shutdown(0));
console.log('==> 启动 Admin API (memind_adm/server)');
server = spawnChild('node', ['server/index.mjs'], 'server');
setTimeout(() => {
console.log('==> 启动管理端 Vite @ http://localhost:5174');
web = spawnChild('npm', ['run', 'dev:web'], 'web');
}, 800);
+10
View File
@@ -0,0 +1,10 @@
# gadm.tkmind.cn → 本机管理端 (vite preview :5174API 反代 :8085)
:8091 {
reverse_proxy 127.0.0.1:5174 {
flush_interval -1
transport http {
read_timeout 0
write_timeout 0
}
}
}