문제

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