feathersjs - how to remotely retrieve available services












0














I want to load service collections into my front end without knowing a priori what they are. I assume I can set up hook on the server that simply walks the service directory and determines the services (subdirectory names) and passes this information back. In fact that information should be in the app instance as a result of the app.configure(services) call?



I've done this before using a get with a special _id that gets hooked and returns other information than a collection record. My issue is that without knowing a service name how can I form a socket request of the featherjs server that gets hooked (like get). I suppose I could always have at least one known service (like users) that I can add that hook to but just wondering if there is a way to do what I want (find out without knowing any service names).



It looks like there are application level hooks https://docs.feathersjs.com/api/application.html#hookshooks so how can I call one of those via socket client and get the result back on the client.



IMHO this should be part of the client api. This would avoid hard coding of service names or having to put them in some custom build config file for the client.










share|improve this question



























    0














    I want to load service collections into my front end without knowing a priori what they are. I assume I can set up hook on the server that simply walks the service directory and determines the services (subdirectory names) and passes this information back. In fact that information should be in the app instance as a result of the app.configure(services) call?



    I've done this before using a get with a special _id that gets hooked and returns other information than a collection record. My issue is that without knowing a service name how can I form a socket request of the featherjs server that gets hooked (like get). I suppose I could always have at least one known service (like users) that I can add that hook to but just wondering if there is a way to do what I want (find out without knowing any service names).



    It looks like there are application level hooks https://docs.feathersjs.com/api/application.html#hookshooks so how can I call one of those via socket client and get the result back on the client.



    IMHO this should be part of the client api. This would avoid hard coding of service names or having to put them in some custom build config file for the client.










    share|improve this question

























      0












      0








      0







      I want to load service collections into my front end without knowing a priori what they are. I assume I can set up hook on the server that simply walks the service directory and determines the services (subdirectory names) and passes this information back. In fact that information should be in the app instance as a result of the app.configure(services) call?



      I've done this before using a get with a special _id that gets hooked and returns other information than a collection record. My issue is that without knowing a service name how can I form a socket request of the featherjs server that gets hooked (like get). I suppose I could always have at least one known service (like users) that I can add that hook to but just wondering if there is a way to do what I want (find out without knowing any service names).



      It looks like there are application level hooks https://docs.feathersjs.com/api/application.html#hookshooks so how can I call one of those via socket client and get the result back on the client.



      IMHO this should be part of the client api. This would avoid hard coding of service names or having to put them in some custom build config file for the client.










      share|improve this question













      I want to load service collections into my front end without knowing a priori what they are. I assume I can set up hook on the server that simply walks the service directory and determines the services (subdirectory names) and passes this information back. In fact that information should be in the app instance as a result of the app.configure(services) call?



      I've done this before using a get with a special _id that gets hooked and returns other information than a collection record. My issue is that without knowing a service name how can I form a socket request of the featherjs server that gets hooked (like get). I suppose I could always have at least one known service (like users) that I can add that hook to but just wondering if there is a way to do what I want (find out without knowing any service names).



      It looks like there are application level hooks https://docs.feathersjs.com/api/application.html#hookshooks so how can I call one of those via socket client and get the result back on the client.



      IMHO this should be part of the client api. This would avoid hard coding of service names or having to put them in some custom build config file for the client.







      feathersjs feathers-hook






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 27 '18 at 18:04









      DKebler

      475615




      475615
























          1 Answer
          1






          active

          oldest

          votes


















          0














          There are security reasons why this is not available by default and returning a list of all services on the client should be done in a way specific to your application.



          On the server you can get an object of all available services via app.services which can be made available to the client fairly straightforwardly through a custom service:



          app.use('/', {
          async find () {
          const services = Object.keys(app.services);

          return { services };
          }
          });


          Now going to the root level (/) will list the names of all available services. You probably also want to make sure to secure the call accordingly so not everybody can know all the endpoints they can attack.






          share|improve this answer





















          • so since you say I need a "custom" service then answer to my question is no, correct? One MUST have at least one service name known to the client a priori in order to discover the other available services. I suppose then using the 'user' service as I proposed would be the best option as almost always there will be such a service for access security.
            – DKebler
            Dec 29 '18 at 18:06












          • I'm not sure I understand your question then. The client has to know about some discovery mechanism so why not use what is already there? Since the name is known, a root level service is a good place for retrieving the information you need.
            – Daff
            Dec 29 '18 at 22:14











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53949094%2ffeathersjs-how-to-remotely-retrieve-available-services%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          There are security reasons why this is not available by default and returning a list of all services on the client should be done in a way specific to your application.



          On the server you can get an object of all available services via app.services which can be made available to the client fairly straightforwardly through a custom service:



          app.use('/', {
          async find () {
          const services = Object.keys(app.services);

          return { services };
          }
          });


          Now going to the root level (/) will list the names of all available services. You probably also want to make sure to secure the call accordingly so not everybody can know all the endpoints they can attack.






          share|improve this answer





















          • so since you say I need a "custom" service then answer to my question is no, correct? One MUST have at least one service name known to the client a priori in order to discover the other available services. I suppose then using the 'user' service as I proposed would be the best option as almost always there will be such a service for access security.
            – DKebler
            Dec 29 '18 at 18:06












          • I'm not sure I understand your question then. The client has to know about some discovery mechanism so why not use what is already there? Since the name is known, a root level service is a good place for retrieving the information you need.
            – Daff
            Dec 29 '18 at 22:14
















          0














          There are security reasons why this is not available by default and returning a list of all services on the client should be done in a way specific to your application.



          On the server you can get an object of all available services via app.services which can be made available to the client fairly straightforwardly through a custom service:



          app.use('/', {
          async find () {
          const services = Object.keys(app.services);

          return { services };
          }
          });


          Now going to the root level (/) will list the names of all available services. You probably also want to make sure to secure the call accordingly so not everybody can know all the endpoints they can attack.






          share|improve this answer





















          • so since you say I need a "custom" service then answer to my question is no, correct? One MUST have at least one service name known to the client a priori in order to discover the other available services. I suppose then using the 'user' service as I proposed would be the best option as almost always there will be such a service for access security.
            – DKebler
            Dec 29 '18 at 18:06












          • I'm not sure I understand your question then. The client has to know about some discovery mechanism so why not use what is already there? Since the name is known, a root level service is a good place for retrieving the information you need.
            – Daff
            Dec 29 '18 at 22:14














          0












          0








          0






          There are security reasons why this is not available by default and returning a list of all services on the client should be done in a way specific to your application.



          On the server you can get an object of all available services via app.services which can be made available to the client fairly straightforwardly through a custom service:



          app.use('/', {
          async find () {
          const services = Object.keys(app.services);

          return { services };
          }
          });


          Now going to the root level (/) will list the names of all available services. You probably also want to make sure to secure the call accordingly so not everybody can know all the endpoints they can attack.






          share|improve this answer












          There are security reasons why this is not available by default and returning a list of all services on the client should be done in a way specific to your application.



          On the server you can get an object of all available services via app.services which can be made available to the client fairly straightforwardly through a custom service:



          app.use('/', {
          async find () {
          const services = Object.keys(app.services);

          return { services };
          }
          });


          Now going to the root level (/) will list the names of all available services. You probably also want to make sure to secure the call accordingly so not everybody can know all the endpoints they can attack.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 28 '18 at 6:05









          Daff

          36.1k783102




          36.1k783102












          • so since you say I need a "custom" service then answer to my question is no, correct? One MUST have at least one service name known to the client a priori in order to discover the other available services. I suppose then using the 'user' service as I proposed would be the best option as almost always there will be such a service for access security.
            – DKebler
            Dec 29 '18 at 18:06












          • I'm not sure I understand your question then. The client has to know about some discovery mechanism so why not use what is already there? Since the name is known, a root level service is a good place for retrieving the information you need.
            – Daff
            Dec 29 '18 at 22:14


















          • so since you say I need a "custom" service then answer to my question is no, correct? One MUST have at least one service name known to the client a priori in order to discover the other available services. I suppose then using the 'user' service as I proposed would be the best option as almost always there will be such a service for access security.
            – DKebler
            Dec 29 '18 at 18:06












          • I'm not sure I understand your question then. The client has to know about some discovery mechanism so why not use what is already there? Since the name is known, a root level service is a good place for retrieving the information you need.
            – Daff
            Dec 29 '18 at 22:14
















          so since you say I need a "custom" service then answer to my question is no, correct? One MUST have at least one service name known to the client a priori in order to discover the other available services. I suppose then using the 'user' service as I proposed would be the best option as almost always there will be such a service for access security.
          – DKebler
          Dec 29 '18 at 18:06






          so since you say I need a "custom" service then answer to my question is no, correct? One MUST have at least one service name known to the client a priori in order to discover the other available services. I suppose then using the 'user' service as I proposed would be the best option as almost always there will be such a service for access security.
          – DKebler
          Dec 29 '18 at 18:06














          I'm not sure I understand your question then. The client has to know about some discovery mechanism so why not use what is already there? Since the name is known, a root level service is a good place for retrieving the information you need.
          – Daff
          Dec 29 '18 at 22:14




          I'm not sure I understand your question then. The client has to know about some discovery mechanism so why not use what is already there? Since the name is known, a root level service is a good place for retrieving the information you need.
          – Daff
          Dec 29 '18 at 22:14


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53949094%2ffeathersjs-how-to-remotely-retrieve-available-services%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Mossoró

          Error while reading .h5 file using the rhdf5 package in R

          Pushsharp Apns notification error: 'InvalidToken'