Skip to content

Commit

Permalink
Simplified redirects to imported apps
Browse files Browse the repository at this point in the history
  • Loading branch information
danjoa committed Feb 17, 2021
1 parent 77de0e4 commit 28402c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fiori/app/bookshop.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<head>
<meta http-equiv="refresh" content="0;url=vue/bookshop/index.html">
<meta http-equiv="refresh" content="0;url=bookshop/index.html">
</head>
2 changes: 1 addition & 1 deletion fiori/app/reviews.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<head>
<meta http-equiv="refresh" content="0;url=vue/reviews/index.html">
<meta http-equiv="refresh" content="0;url=reviews/index.html">
</head>
21 changes: 10 additions & 11 deletions fiori/server.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
const express = require ('express')
const cds = require ('@sap/cds')

cds.once('bootstrap',(app)=>{
const {dirname} = require ('path')
// serving the orders app imported from @capire/orders
const orders_app = dirname (require.resolve('@capire/orders/app/orders/webapp/manifest.json'))
app.use ('/orders/webapp', express.static(orders_app))
// serving the vue.js app imported from @capire/bookshop
const bookshop_app = dirname (require.resolve('@capire/bookshop/app/vue/index.html'))
app.use ('/vue/bookshop', express.static(bookshop_app))
// serving the vue.js app imported from @capire/reviews
const reviews_app = dirname (require.resolve('@capire/reviews/app/vue/index.html'))
app.use ('/vue/reviews', express.static(reviews_app))
app.use ('/orders/webapp', _from('@capire/orders/app/orders/webapp/manifest.json'))
app.use ('/bookshop', _from('@capire/bookshop/app/vue/index.html'))
app.use ('/reviews', _from('@capire/reviews/app/vue/index.html'))
})

cds.once('served', require('./srv/mashup'))

module.exports = cds.server


// -----------------------------------------------------------------------
// Helper for serving static content from npm-installed packages
const {static} = require('express')
const {dirname} = require('path')
const _from = target => static (dirname (require.resolve(target)))

0 comments on commit 28402c5

Please sign in to comment.