User controller

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 ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.