Friday, 11 January 2019

Clean Up Requires in Express App

I'm trying to clean up my code but I have probably 20 requires in my app.js file looking like:const app = require('express');const yada = require('yada');const dada = require('dada');and so on.Is it possible to put all of those requires in a separate file and then require that one file?I tried this by:const app = require('express');const myModel = require('myModel');module.exports = {app, myModel};but when I try to create an instance of myModel I get the error:TypeError: myModel is not a constructor​Edit: inline code formatting

Submitted January 11, 2019 at 03:57PM by Wesabi627

No comments:

Post a Comment