2 weeks ago
Hello,
I am implementing a CAP CDS Service in NodeJS. I would like to use a custom handler for the same.
Example: in the CAP CDS folder srv, I have following file
TestService.cds (Contents)
namespace test.ns.srv;
service TestService {
function testFunction() returns Integer;
}
How should the implementation in TestImplementation.js look? All examples show the service without a namespace and the handler looks like this
class TestService extends cds.ApplicationService {
........
this.on("testFunction", async (req) => { });
}
The above construct works perfectly fine when the TestService.cds definition does not have a namespace. But with namespace, CDS does not link the handler implementation with the service.
Thank you
The exports' names must match the servce definitions' fully-qualified names.
Extract from the following part of documentation in https://cap.cloud.sap/docs/node.js/core-services
In case you have multiple service definition is one .cds file like that:
// services.cds namespace foo.bar; service Foo {...} service Bar {...}
... you may also want to have multiple implementations provided through one corresponding .js file. Simply do so by by having multiple exports like that:
// services.js exports['foo.bar.Foo'] = class Foo {...} exports['foo.bar.Boo'] = class Bar {...}
The exports' names must match the servce definitions' fully-qualified names.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.