Initial commit

Next.js + Express event management app for Hope Family Church.
This commit is contained in:
2026-07-23 15:26:47 +02:00
commit 3d381944d2
246 changed files with 57565 additions and 0 deletions
@@ -0,0 +1,44 @@
const fs = require('fs');
const path = require('path');
const BANNER_FILE = path.join(__dirname, '../../data/banner.json');
function readBanner() {
try {
const raw = fs.readFileSync(BANNER_FILE, 'utf8');
return JSON.parse(raw);
} catch {
return { message: '', type: 'info', liveFrom: null, liveTill: null };
}
}
function writeBanner(data) {
fs.writeFileSync(BANNER_FILE, JSON.stringify(data, null, 2), 'utf8');
}
// @desc Get the current banner
// @route GET /api/banner
// @access Public
const getBanner = (req, res) => {
res.json(readBanner());
};
// @desc Set the banner
// @route POST /api/banner
// @access Supervisor / Admin
const setBanner = (req, res) => {
const { message, type, liveFrom, liveTill } = req.body;
const allowed = ['info', 'warning', 'success', 'danger'];
const banner = {
message: typeof message === 'string' ? message.trim() : '',
type: allowed.includes(type) ? type : 'info',
liveFrom: liveFrom || null,
liveTill: liveTill || null,
};
writeBanner(banner);
res.json(banner);
};
module.exports = { getBanner, setBanner };