TODO: Remove the throw new Error statements and replace them with a res.status(some_code).json({error: some_error}) statement .