I have a three koa application and the structure of this these application is like this :

  • app.js

  • directory app2

    • app2.js
  • directory app3

    • app3.js

    i try to mount app2.js and app3.js on app.js using koa-mount package but i get an error :

     var name = app.name || 'unnamed';
            ^
    TypeError: Cannot read property 'name' of undefined
    

so the question is how to load different koa application as middleware that exists in different directory?

有帮助吗?

解决方案

Solution

according to this github issue app2.js and app3.js should be a module so use module.exports and the in app.js require them as a variable and then mount the variable on specific route variable and then mount the variable on specific route

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top