Skip to Content
0
Jun 17, 2020 at 10:56 AM

How to run cds service module with node.js code locally

1382 Views

Hello all,

We used Web IDE to develop a CAP node.js project, since AppStudio is the next generation of Web IDE, we decide to switch to AppStudio, this project refers to Thomas Jung 's repository https://github.com/SAP-samples/hana-xsa-opensap-hana7/blob/hana2_sps04_scp/srv/server.js#L79, there are cds services and custom routes, node server.js is used to start the application. We can run and debug it successfully in Web IDE. After we clone this project into AppStudio, we can build mta and deploy it to cf, it runs successfully, we could not make it run/debug locally anymore. Here are my findings:

  • If use cds watch to run this project, all cds services work as expected(default-env.json is used to connect to hdi), but custom routes throws Cannot get <path> error. This is expected because we are not using node server.js, then custom routes are not loaded.
  • If we use node server.js to run this project, I suppose default-services.json is used to connect to hdi, in this case cds services will not work, throws error Cannot read property 'schema' of undefined, since no hdi parameters are provided. Custom routes which tried to connect to hdi throw error only secure connections are allowed. If we use hdbext middleware, all requests end with error Connection failed (RTE:[300002] OpenSSL is not available: Unresolved symbol.

My questions:

  • Is it possible to run this kind of cds/node.js project in AppStudio and how?
  • If not does it mean this project needs to be split into 2 projects 1 pure cds and 1 pure node.js, what is the best practice to connect to hdi in node.js+AppStudio?

I know this is a lot information, really appreciate your time and any feedback is welcome.

Best Regards,

Mike

Code samples:

server.js https://github.com/SAP-samples/hana-xsa-opensap-hana7/blob/hana2_sps04_scp/srv/server.js#L79

custom route https://github.com/SAP-samples/hana-xsa-opensap-hana7/blob/hana2_sps04_scp/srv/router/routes/hanaClient.js