Pregunta

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?

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top