Disclaimer: This is my first time: using node, creating a REST API, and trying out MVC server side. (so, just statistically speaking, I'm probably doing something wrong \_()_/)I'm working on creating a video sharing platform for use at my university. It's going to be a single page application with client side routing. I plan on making ajax requests to a REST API for the CRUD functionality. The basic structure I have going so far is that my controllers are  receiving the routing requests and calling the model functions to interact with the DB. For example:controllers/courses.js:var express = require('express');var router = express.Router();var models = {};models.courses = require('../models/courses.js');router.get('/api/courses', models.courses.get_all);router.get('/api/courses/:id', models.courses.get);router.post('/api/courses', models.courses.create);router.put('/api/courses/:id', models.courses.update);router.delete('/api/courses/:id', models.courses.delete);models/courses.js:var db = require('../config/db_config.js');exports.get_all = function (req, res, next) {    db.any('select * from course')    .then(function (data) {        res.status(200).json({            status: 'success',            data: data,            message: 'Retrieved all courses'        });    })    .catch(function (err) {        return next(err);    });};exports.get = function (req, res, next) {    db.one('select * from course where id = $1', req.params.id)    .then(function (data) {        res.status(200).json({            status: 'success',            data: data,            message: 'Retrieved a course'        });    })    .catch(function (err) {        console.log(err);        return next(err);    });};Is this more or less the right way to do it? Do you forsee me running into issues down the road?My gut says that the model code should be passing the query results back to the controller, rather than directly back to the client. Is this correct? If so, how would I go about that? Tell me what you would do differently. 
Should models be returning data directly to the client, or to the controller instead?
javascript;mvc;rest;node.js;separation of concerns
Here is how MVC is intended to work...The controller receives the request from the client, performs any business rules logic to determine and implement the changes to the model that are required. The final part is that it selects the appropriate model and view to return to the client. The View defines the presentation of the model to the client.I have a second observation to make. If you implement a REST api to deliver a CRUD service you need to be in complete control of all clients that can connect to the REST API. If, as it seems from your question, that the clients are javascript code running in the web browser, then you cannot be in control of all clients, as someone could write their own client to access your CRUD API, and manipulate the back end objects as they see fit.Hopefully, you mean that you are implementing a REST API that includes the business rules authenticating and validating requests as well as performing object updates.