The server/controllers/user.controller.js file will contain the controller methods used in the preceding user route declarations as callbacks when a route request is received by the server.
The user.controller.js file will have the following structure:
import User from '../models/user.model'import _ from 'lodash'import errorHandler from './error.controller'const create = (req, res, next) => { … }const list = (req, res) => { … }const userByID = (req, res, next, id) => { … }const read = (req, res) => { … }const update = (req, res, next) => { … }const remove = (req, res, next) => { … }export default { create, userByID, read, list, remove, update }
The controller will make use of the errorHandler helper to respond to the route ...