hapipal / hpal

hapi pal CLI
https://hapipal.com
MIT License
51 stars 7 forks source link

"registerService" is not a method on the passed server #34

Closed codechips closed 5 years ago

codechips commented 5 years ago

Not sure if it's a hpal issue, but certainly related to it or one of the hapipal family modules. The hpal generated project fails to register new Schmervice services with the following error:

AssertionError [ERR_ASSERTION]: "registerService" is not a method on the passed server.
    at new AssertionError (internal/assert.js:269:11)

Steps to reproduce: 1) Create a new hpal project (hpal new test_project && cd test_project && npm i) 2) Create a route and fill in the details (hpal new route root) 3) Install schmervice (npm i schmervice) 4) Create a new service (hpal new service simple) 5) Server now fails to start.

It used to work earlier, so my guess that it's some module change down the line that's causing trouble.

devinivy commented 5 years ago

It sounds like you're using haute-couture to create a service but schmervice hasn't actually been registered as a plugin. Try registering schmervice and let us know if it keeps giving you issues! Here's a shortcut:mkdir lib/plugins && echo "'use strict';\n\nmodule.exports = {};\n" > lib/plugins/schmervice.js.

codechips commented 5 years ago

Yep. Worked. Thanks a lot for the swift reply 👍

sebastianhelbig commented 3 years ago

@devinivy How to do this, now that schmervice is named "@hapipal/schmervice"? Thanks a lot.

devinivy commented 3 years ago

@sebastianhelbig You can register the plugin onto the server yourself:

await server.register('@hapipal/schmervice');

Or if you're using haute-couture and the pal boilerplate you can simply create a file named lib/plugins/@hapipal.schmervice.js exporting an empty object (i.e. no plugin configuration). Here's an example: https://github.com/devinivy/hapipal-realworld-example-app/blob/main/lib/plugins/%40hapipal.schmervice.js.