This commit is contained in:
2026-04-27 20:29:21 +02:00
parent 329ed5adb0
commit b928212608
10 changed files with 329 additions and 7 deletions

View File

@@ -0,0 +1,32 @@
const express = require('express')
const router = express.Router();
const Campaign = require("../models/Campaign");
router.post('/create', async (req, res) => {
try {
const { name, description, color, settings } = req.body;
const newCampaign = new Campaign({
name,
description,
color,
settings,
createdBy: req.user.id
});
await newCampaign.save();
res.json({ status: "ok", campaign: newCampaign });
} catch (err) {
res.json({ status: "error", msg: "errors.internal" });
}
});
router.get('/list', async (req, res) => {
try {
const campaigns = await Campaign.find({ createdBy: req.user.id });
res.json({ status: "ok", campaigns });
} catch (err) {
res.json({ status: "error", msg: "errors.internal", err });
}
});
module.exports = router;