senecajs / seneca-web

Http route mapping for Seneca microservices.
MIT License
76 stars 44 forks source link

Can't run with hapi #140

Closed shijiebei2014 closed 5 years ago

shijiebei2014 commented 5 years ago

This is the parts of code: var config = { routes: Routes, adapter: require('seneca-web-adapter-hapi'), context: Hapi.server({port: 4000}) } var seneca = Seneca() .use(SenecaWeb, config) .ready(async ()=> { var server = seneca.export('web/context')() try { var promise = await server.start() // TypeError: Method Map.prototype.forEach called on incompatible receiver # console.log('server started on: ' + server.info.uri) } catch(e) { console.error('err:', e) } })

shijiebei2014 commented 5 years ago

I'm confused about that config.context !== seneca.export('web/context')()

tswaters commented 5 years ago

Config.context should be the same as seneca.export('web/context')() - if not, very similar.

Last I checked the tests for the adapter pass. That build can be seen here -- https://travis-ci.org/senecajs/seneca-web-adapter-hapi/builds/164535179 -- tests here: https://github.com/senecajs/seneca-web-adapter-hapi/blob/master/test/hapi.test.js -- it all looks very similar to yours. That is running an older version of hapi, though - v15 - maybe hapi has been updated and no longer supports this?

I do know that koa2 had some similar troubles passing the entire application through context like that - to the point where I needed to provide a Router instead -- see https://github.com/senecajs/seneca-web-adapter-koa2#note ... perhaps hapi has a problem with this now as well? Does hapi have some kind of concept of a light-weight Router that one can attach routes to and pass through context ?

seneca-web-adapter-hapi is probably the correct repository for a bug like: https://github.com/senecajs/seneca-web-adapter-hapi/ -- and, I would most definitely need help on any ticket added there. I don't know the first thing about hapi.... more of a connect/express/koa developer.

shijiebei2014 commented 5 years ago

I need to invoke the function named "web/mapRoutes" to inject the routes and start the server with config.server

shijiebei2014 commented 5 years ago

It's the bug of seneca;