Closed sedacrivity closed 6 years ago
Any feedback would be appreciated ... thanks :-)
Hi, Steven, I'm a little lost with the quotes to the different pieces in the tutorials, what the interpretation is with the express module and what the ask is there.
There is nothing happening automatically with the express module. The xs-app.json should have been done already (here: https://www.sap.com/developer/tutorials/xsa-xsjs-xsodata.html ), but it depends on what you have done so far.
Was it working at that point? Would like to help but need more information on what you've done, what your project looks like and what URl you are aiming at (I'm assuming the web URL or you should be getting a different error).
Also, there is more of us monitoring the Q&A if you are looking for a more timely response.
Best,
Lucia.
Hi Lsubatin,
Thanks for your response ... let me restart/rephrase then ...
I have created a node js module project with the flag 'xsjs compatibility'. I added the server initialization to include the xsjs sap library as well within express.
I have setup a couple of node js routes which work fine.
Within the tutorial it is stated ( and I quote ) "Then you will add the XSJS as a root route handler".
So the quoted text lets me assume that - besides my own node js routes - there would also be a default XSJS route handler be available now ( for which I don't need to do anything in particular ). I also don't see anything special being done in that section of the tutorial where the quote is made nor do I see anything special done anywhere else.
I also have a web app router with a route which routes any xjsjs request towards the above node module.
And still I am not able to get any url which points towards my xsjs to work ... my other node js routes work fine ... so I was wondering what I am missing ? Or am I misunderstanding the quoted text ?
Or maybe bottom line ... can one 'mix' within the same module normal node routes and the xsjs (default) routing ? I have a feeling one can't ...
Hmmm nevermind .. somehow the issue resolved itself and I am now perfectly able to access both XSJS and normal node.js routes within the same module ... not sure what changed though.
Hi, Steven... That's what I call witchcraft....
I'm updating those tutorials for SPS03 and will check on that text. I think it's giving the wrong idea, as there is no default handler. The web module acts as the routing endpoint and relies on the config in xs-app.json or any other routes you can do in the node.js module itself so both XSJS and node.js can coexist.
Hope you don't need any more sorcery!
Best,
Lucia.
Do you have any example on this - using the xsjs router and separate nodejs (express) routes within the same application? How do you do this in a way that you only define one server - single listen().
Do you have any example on this - using the xsjs router and separate nodejs (express) routes within the same application? How do you do this in a way that you only define one server - single listen().
I have the same question here, it would be great to see how it works.
You want a single module that does both pure Node.js (Express routes) and XSJS in one? We used to show that scenario, but it is no longer supported. XSJS uses Express internally and needs some control over it that makes it incompatible with running within another instance of Express. So please simply create two separate modules/services for your XSJS and pure Node.js content. Or consider converting your XSJS/XSODATA to Node.js and/or CAP which can then all be combined in one module.
Hi Thomas, Thank you so much for replying @jung-thomas, in our project we also use DocStore which is not supported by CAP CDS yet, so we have 3 Node.js modules: 1 XSJS module for DocStore, 1 CDS module for normal HANA tables and 1 pure Node.js module for Node.js code development, how to combine those modules? I do not find a tutorial on how to write Node.js or XSJS in CDS, convert XSJS/XSODATA to Node.js means we lost the features provided by XSJS, we have to write more codes manually, right? Could you please guide us how to improve this setup, thank you.
Best Regards, Mike
The 1 CDS module - you mean a Node.js module for CDS services? If so that can easily be combined with your pure Node.js module. See the example from the openSAP HANA7 course were we do exactly that. https://github.com/SAP-samples/hana-xsa-opensap-hana7/tree/hana2_sps04/srv
I'm not sure what manual coding you'd have to do compared to XSJS. If you were specific about what you were doing in XSJS I could perhaps point you to an example in Node.js.
Really this isn't a discussion we should be having in the tutorial issues. This is for specific problems with a tutorial. I'd suggest that such discussions/questions should really be better served in the SAP Community Q&A instead.
Hi Thomas, Agree that SAP Community Q&A is a better place for this question, Google pointed to this post when I searched how to make XSJS and Node.js coexist:). It's great to see the sample on how to combine pure Node.js module with CDS, this is not mentioned in capire https://cap.cloud.sap/docs/. My XSJS module contains only CRUD operations to HANA DocStore tables, executes SELECT, UPDATE, DELETE SQL statements and nothing else, if I could combine it with CDS module(Node.js module), then 3 modules become 1 module which simplify the project setup, could you please point me an example of HANA CRUD operations in pure Node.js? I am new to Node.js and HANA so this is probably a silly question, thank you.
Best Regards, Mike
There are some samples of CRUD operations in Node.js in that same repository I linked to earlier. You can send SQL Statements to the DB using the @sap/hdbext module. https://github.com/SAP-samples/hana-xsa-opensap-hana7/blob/hana2_sps04/srv/router/routes/ex2.js
This content is also covered in several openSAP HANA courses (HANA5, HANA6, and HANA7).
As far as the combination of CDS and pure Node.js in the capire docs - it is discussed here: https://cap.cloud.sap/docs/node.js/api#cds-serve
Hi there,
Got a question regarding step 2 - "Add XSJS Initialization".
As far as I understand it - this step allows that xsjs can still be called although we now have node js routing (with our custom routes).
The description states "Then you will add the XSJS as a root route handler".
I read the above as that somehow automatically allows express to know how to handle xsjs calls.
Now I am probably overlooking something but I am not able to execute any xsjs resource sitting under the lib folder or even the 'index.xsjs' file ... I always get a 404 not found. I have tried a zillion possible url combinations ... no luck. I tried adding a specific route for .xsjs to the xs-app.json of my web app but no luck.
What am I overlooking ? What is the correct url then to call xsjs objects ?
Thanks,
Steven