feat: migrate Event and Reward models from MongoDB to CouchDB
- Replace Event model with CouchDB version using couchdbService - Replace Reward model with CouchDB version using couchdbService - Update event and reward routes to use new model interfaces - Handle participant management with embedded user data - Maintain status transitions for events (upcoming, ongoing, completed, cancelled) - Preserve catalog functionality and premium vs regular rewards - Update validators to accept CouchDB document IDs - Add rewards design document to couchdbService - Update test helpers for new model structure - Initialize CouchDB alongside MongoDB in server.js for backward compatibility - Fix linting issues in migrated routes 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
require("dotenv").config();
|
||||
const express = require("express");
|
||||
const mongoose = require("mongoose");
|
||||
const couchdbService = require("./services/couchdbService");
|
||||
const cors = require("cors");
|
||||
const http = require("http");
|
||||
const socketio = require("socket.io");
|
||||
@@ -58,7 +59,8 @@ const apiLimiter = rateLimit({
|
||||
legacyHeaders: false,
|
||||
});
|
||||
|
||||
// MongoDB Connection
|
||||
// Database Connections
|
||||
// MongoDB (for backward compatibility during migration)
|
||||
mongoose
|
||||
.connect(process.env.MONGO_URI, {
|
||||
useNewUrlParser: true,
|
||||
@@ -67,6 +69,11 @@ mongoose
|
||||
.then(() => console.log("MongoDB connected"))
|
||||
.catch((err) => console.log("MongoDB connection error:", err));
|
||||
|
||||
// CouchDB (primary database)
|
||||
couchdbService.initialize()
|
||||
.then(() => console.log("CouchDB initialized"))
|
||||
.catch((err) => console.log("CouchDB initialization error:", err));
|
||||
|
||||
// Socket.IO Authentication Middleware
|
||||
io.use(socketAuth);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user