feat: Einführung von Umgebungsvariablen und Startskripten für die Backend-Anwendung
- Hinzufügen eines zentralen Skripts zum Laden von Umgebungsvariablen aus einer .env-Datei. - Implementierung von Start- und Entwicklungs-Skripten in der package.json für eine vereinfachte Ausführung der Anwendung. - Bereinigung und Entfernung nicht mehr benötigter Minigame-Modelle und -Services zur Verbesserung der Codebasis. - Anpassungen an den Datenbankmodellen zur Unterstützung von neuen Assoziationen und zur Verbesserung der Lesbarkeit.
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
import MinigamesService from '../services/minigamesService.js';
|
||||
|
||||
function extractHashedUserId(req) {
|
||||
return req.headers?.userid;
|
||||
}
|
||||
|
||||
class MinigamesController {
|
||||
constructor() {
|
||||
this.service = MinigamesService;
|
||||
|
||||
this.listCampaigns = this._wrap((userId, req) => this.service.listCampaigns());
|
||||
this.getCampaign = this._wrap((userId, req) => this.service.getCampaign(req.params.code));
|
||||
this.getProgress = this._wrap((userId, req) => this.service.getProgress(userId, req.params.code));
|
||||
this.saveProgress = this._wrap((userId, req) => this.service.saveProgress(userId, req.params.code, req.body));
|
||||
}
|
||||
|
||||
_wrap(fn, { successStatus = 200 } = {}) {
|
||||
return async (req, res) => {
|
||||
try {
|
||||
const userId = extractHashedUserId(req);
|
||||
if (!userId) return res.status(400).json({ error: 'Missing user identifier' });
|
||||
const result = await fn(userId, req, res);
|
||||
res.status(successStatus).json(result);
|
||||
} catch (error) {
|
||||
console.error('Minigames controller error:', error);
|
||||
res.status(500).json({ error: error.message || 'Internal error' });
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default new MinigamesController();
|
||||
|
||||
Reference in New Issue
Block a user