简体   繁体   中英

Any way of stop repeating while exporting functions in node?

I'm writing a small API for fun in express, there's any way i can stop repeating eg module.exports or usuariosControllers?

module.exports.getUsuarios = (request, response) => {};

module.exports.crearUsuario = (request, response) => {};

module.exports.getUsuario = (request, response) => {};

module.exports.eliminarUsuario = (request, response) => {};

module.exports.getOrdenes = (request, response) => {};

module.exports.crearOrden = (request, response) => {};

module.exports.getOrden = (request, response) => {};

module.exports.modificarOrden = (request, response) => {};

You are almost there.

module.exports = {
  getUsuarios: (req, res) => { 
     //something 
   },

  crearUsuario: (req, res) => {
  },
  //continue in this manner
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM