Bündelt die Neuentwicklung in AssigmentMonitorV2 (eigene Ports/DB), die Umstellung auf numerische Bewertungen, Meeting-Checklisten, KI-Tagging und die geplante Feedback-Kaskade — als Basis für Versionsverwaltung in Gitea. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import express from 'express'
|
|
import './database'
|
|
import { rpcModules } from './rpcModules'
|
|
|
|
const app = express()
|
|
app.use(express.json({ limit: '50mb' })) // Backup-Import kann alle Tabellen als ein JSON-Body enthalten
|
|
|
|
app.post('/api/rpc', (req, res) => {
|
|
const { module, fn, args } = req.body as { module?: string; fn?: string; args?: unknown[] }
|
|
|
|
const mod = module ? rpcModules[module] : undefined
|
|
const handler = fn ? mod?.[fn] : undefined
|
|
if (!mod || typeof handler !== 'function') {
|
|
res.json({ ok: false, error: `Unbekannte RPC-Zielfunktion: ${module}.${fn}` })
|
|
return
|
|
}
|
|
|
|
try {
|
|
const result = handler(...(args ?? []))
|
|
res.json({ ok: true, result: result ?? null })
|
|
} catch (err) {
|
|
res.json({ ok: false, error: err instanceof Error ? err.message : 'Unbekannter Server-Fehler' })
|
|
}
|
|
})
|
|
|
|
/** V2-Default 4001 — Produktiv bleibt auf 4000. */
|
|
const port = process.env.API_PORT ? Number(process.env.API_PORT) : 4001
|
|
if (!Number.isFinite(port) || port === 4000) {
|
|
throw new Error(
|
|
`[server] SAFETY: API_PORT=${process.env.API_PORT ?? '(unset)'} ist ungültig oder kollidiert mit Produktiv-Port 4000. ` +
|
|
`V2 erwartet z.B. 4001 (siehe .env).`,
|
|
)
|
|
}
|
|
|
|
app.listen(port, () => {
|
|
console.log(`[server] DEV-RPC-API (AssignmentMonitorV2) auf http://localhost:${port}/api/rpc`)
|
|
console.log(`[server] Produktiv (AssigmentMonitor) nutzt Port 4000 — diese Instanz ist davon getrennt.`)
|
|
})
|