diff --git a/app/router/orders b/app/router/orders new file mode 120000 index 00000000..9967c858 --- /dev/null +++ b/app/router/orders @@ -0,0 +1 @@ +../../orders/app/orders \ No newline at end of file diff --git a/app/router/xs-app.json b/app/router/xs-app.json index 03a89379..086dae6f 100644 --- a/app/router/xs-app.json +++ b/app/router/xs-app.json @@ -58,6 +58,12 @@ "target": "/user/$1", "destination": "bookstore-api", "csrfProtection": true + }, + { + "source": "^(.*)$", + "target": "$1", + "localDir": ".", + "cacheControl": "no-cache, no-store, must-revalidate" } ] } diff --git a/bookstore/srv/mashup.js b/bookstore/srv/mashup.js index c92840a9..9a6f742b 100644 --- a/bookstore/srv/mashup.js +++ b/bookstore/srv/mashup.js @@ -26,10 +26,11 @@ module.exports = async()=>{ // called by server.js // // Create an order with the OrdersService when CatalogService signals a new order // - CatalogService.on ('OrderedBook', async (msg) => { + const messaging = await cds.connect.to('messaging') + messaging.on('CatalogService.OrderedBook', async (msg) => { const { book, quantity, buyer } = msg.data - const { title, price } = await db.tx(msg).read (Books, book, b => { b.title, b.price }) - return OrdersService.tx(msg).create ('Orders').entries({ + const { title, price } = await db.read (Books, book, b => { b.title, b.price }) + return OrdersService.create ('OrdersNoDraft').entries({ OrderNo: 'Order at '+ (new Date).toLocaleString(), Items: [{ product:{ID:`${book}`}, title, price, quantity }], buyer, createdBy: buyer diff --git a/event-mesh.json b/event-mesh.json index 964f3b44..08d38f47 100644 --- a/event-mesh.json +++ b/event-mesh.json @@ -1,7 +1,7 @@ { - "emname": "samples-emname", + "emname": "samples-multi-service-shared-db", "version": "1.1.0", - "namespace": "default/samples/1", + "namespace": "cap/samples/shdb", "options": { "management": true, "messagingrest": true, @@ -10,7 +10,7 @@ "rules": { "topicRules": { "publishFilter": [ - "${namespace}/*" + "*" ], "subscribeFilter": [ "*" @@ -18,10 +18,10 @@ }, "queueRules": { "publishFilter": [ - "${namespace}/*" + "*" ], "subscribeFilter": [ - "${namespace}/*" + "*" ] } }, diff --git a/mta.yaml b/mta.yaml index f768d005..7883b9b5 100644 --- a/mta.yaml +++ b/mta.yaml @@ -100,6 +100,7 @@ modules: - name: samples-messaging - name: samples-db - name: samples-auth + - name: samples-destination - name: samples-db-deployer type: hdb diff --git a/orders/srv/orders-service.cds b/orders/srv/orders-service.cds index 119373db..4ba279c2 100644 --- a/orders/srv/orders-service.cds +++ b/orders/srv/orders-service.cds @@ -2,4 +2,8 @@ using { sap.capire.orders as my } from '../db/schema'; service OrdersService { entity Orders as projection on my.Orders; + + @odata.draft.bypass + @(requires: 'system-user') + entity OrdersNoDraft as projection on my.Orders; }