Grundgerüst mit Server, PIN-Anmeldung und Docker-Deploy aufbauen
Die alte Clip-Auswahl-Oberfläche entfällt. Neu sind ein Express-Server, der im Entwicklungsbetrieb Vite einbindet, eine PIN-Anmeldung mit signiertem Sitzungs-Cookie und ein Docker-Image mit ffmpeg für VCH. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8ed1396b1c
commit
f7d249f28b
23 files changed
+4456
-1358
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import http from 'node:http';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import express from 'express';
|
||||
import { createApp } from './app.js';
|
||||
import { loadSessionSecret } from './auth.js';
|
||||
import { loadConfig } from './config.js';
|
||||
|
||||
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
const config = loadConfig();
|
||||
if (!config.pin) {
|
||||
console.warn('APP_PIN ist nicht gesetzt – Anmeldung ist nicht möglich.');
|
||||
}
|
||||
|
||||
const app = createApp({ config, secret: loadSessionSecret(config) });
|
||||
const server = http.createServer(app);
|
||||
|
||||
if (config.isProduction) {
|
||||
const distDir = path.join(rootDir, 'dist');
|
||||
app.use(express.static(distDir));
|
||||
app.use((req, res, next) => {
|
||||
if (req.method !== 'GET') return next();
|
||||
res.sendFile(path.join(distDir, 'index.html'));
|
||||
});
|
||||
} else {
|
||||
// Im Entwicklungsbetrieb liefert Vite das Frontend über denselben Port aus.
|
||||
const { createServer } = await import('vite');
|
||||
const vite = await createServer({
|
||||
root: rootDir,
|
||||
appType: 'spa',
|
||||
server: { middlewareMode: true, hmr: { server } },
|
||||
});
|
||||
app.use(vite.middlewares);
|
||||
}
|
||||
|
||||
server.listen(config.port, '0.0.0.0', () => {
|
||||
console.log(`FuerDieCuts läuft auf Port ${config.port}`);
|
||||
});
|
||||
Reference in new issue
Block a user