Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run with hapi #140

Closed
shijiebei2014 opened this issue Apr 6, 2019 · 4 comments
Closed

Can't run with hapi #140

shijiebei2014 opened this issue Apr 6, 2019 · 4 comments

Comments

@shijiebei2014
Copy link

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
Copy link
Author

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

@tswaters
Copy link
Member

tswaters commented Apr 6, 2019

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
Copy link
Author

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

@shijiebei2014
Copy link
Author

It's the bug of seneca;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants