i got a mysql table in which are stored the available plugins for some users. I've written a function that mounts all the plugin routes and it goes like this (leaving error handling and file checking) :
var requireEnrolPlugins = function(app){
connection.query('Select name FROM ... where type = ?,[enrol],
(err,rows,fields) => {
async.eachOfSeries(rows,function(item,key,eachOfCallback){
require('path/to/plugin-dir/ ' + item.name + '/routes.js')(app);
eachOfCallback();
})
})
}
this function is called in a index.js file where all the routes are mounted, then the index.js file is declared in the app.js main file If i try to require without the appEngine handler, it goes ok. But if i add the (app) engine at the and of the require, it throws this error :
require(...) is not a function
at C:\Users\username\Desktop\node-
projects\project\functions\general_functions.js:70:33
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
Anyone can help me? Thank you !
via Ermanno Palmizio Salieri
No comments:
Post a Comment