diff --git a/src/index.js b/src/index.js index 30586f6..1c7fe2a 100644 --- a/src/index.js +++ b/src/index.js @@ -76,7 +76,14 @@ const mapRoutes = (routes, pathToController, middlewareGenerals = []) => { } catch (err) { require('@babel/register'); handler = require(`${myPathToController}${controller}`).default; - contr = new handler(); + + isConstructable = isConstructor(handler); + + if (isConstructable) { + contr = new handler(); + } else { + contr = handler(); + } } router.route(myPath)[requestMethod](middlewares, contr[controllerMethod]);