controllers/statesController.js

/**
 * This controller handles the logic for any states related routes.
 * @module Controllers/StatesController
 */

const StateModel = require('../models/stateModel.js')

/**
 * Get all of the States
 */
exports.index = (req, res) => {
  // initialize instance of StateModel
  const state = new StateModel(req)

  // read the States file and send it to client
  state.getAll(req)
    .then(result => {
      res.send(result)
      // todo add error handling
    })
}