OwlCyberSecurity - MANAGER
Edit File: room.controller.js
// controllers/roomController.js import { Room, Section } from '../models/index.js'; export const getRooms = async (req, res) => { try { const rooms = await Room.findAll({ include: [{ model: Section, attributes: ['id', 'section'] }], }); res.json(rooms); } catch (error) { console.error('Error fetching rooms:', error); res.status(500).json({ message: 'Internal server error' }); } }; export const createRoom = async (req, res) => { try { const room = await Room.create(req.body); res.status(201).json(room); } catch (error) { console.error('Error creating room:', error); res.status(500).json({ error: 'Failed to create room' }); } };