Implement inserting notifications when a monitor is created, update validation

This commit is contained in:
Alex Holliday
2024-07-31 12:12:05 -07:00
parent 40c550e81f
commit 09edaebd98
3 changed files with 17 additions and 5 deletions
+2 -1
View File
@@ -30,7 +30,6 @@ const getAllMonitors = async (req, res) => {
*/
const getMonitorById = async (req, res) => {
try {
const { monitorId } = req.params;
let { status, limit, sortOrder } = req.query;
@@ -140,6 +139,8 @@ const getMonitorsByUserId = async (req, res) => {
const createMonitor = async (req, res) => {
try {
const monitor = new Monitor({ ...req.body });
// Remove notifications fom monitor as they aren't needed here
delete monitor.notifications;
monitor.userId = req.user._id;
await monitor.save();
return monitor;