diff --git a/.gitignore b/.gitignore index 1951715e..ae1e0fdb 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ default-env.json packages/messageBox reviews/msg-box reviews/db/test.db + +package-lock.json +logs_recent_*.txt \ No newline at end of file diff --git a/logs_recent_2.txt b/logs_recent_2.txt deleted file mode 100644 index 5d0ffc50..00000000 Binary files a/logs_recent_2.txt and /dev/null differ diff --git a/logs_recent_3.txt b/logs_recent_3.txt deleted file mode 100644 index f86ed80b..00000000 Binary files a/logs_recent_3.txt and /dev/null differ diff --git a/multitenancy/Makefile_20210504145509.mta b/multitenancy/Makefile_20210504145509.mta new file mode 100644 index 00000000..f180c886 --- /dev/null +++ b/multitenancy/Makefile_20210504145509.mta @@ -0,0 +1,54 @@ +# Generated with Cloud MTA Build Tool version 1.0.14 +version=0.0.1 +MBT=/usr/local/lib/node_modules/mbt/unpacked_bin/mbt +ifndef p +$(error platform flag is expected. e.g. use make -f makefile.mta p=cf) +endif +target_provided=true +ifndef t +t="$(CURDIR)" +target_provided=false +endif +ifndef strict +strict=true +endif +ifndef mtar +mtar="*" +endif +modules := $(shell $(MBT) provide modules -d=dev) +modules := $(subst ],,$(subst [,,$(modules))) +# List of all the recipes to be executed during the build process +.PHONY: all pre_validate pre_build validate $(modules) post_build meta mtar cleanup +# Default target compile all +all: pre_validate pre_build validate $(modules) post_build meta mtar cleanup +# Validate mta.yaml +pre_validate: + @$(MBT) validate -r=${strict} -x="paths" +pre_build: pre_validate + @$(MBT) project build -p=pre + + +# Execute module build +define build_rule +$(1): validate + @$(MBT) module build -m=$(1) -p=${p} -t=${t} +endef + +$(foreach mod,$(modules),$(eval $(call build_rule,$(mod))))# Create META-INF folder with MANIFEST.MF & mtad.yaml +meta: $(modules) post_build + @$(MBT) gen meta -p=${p} -t=${t} + +post_build: $(modules) + @$(MBT) project build -p=post -t=${t} + +# Validate mta.yaml +validate: pre_build + @$(MBT) validate -r=${strict} + +# Pack as MTAR artifact +mtar: $(modules) meta + @$(MBT) gen mtar --mtar=${mtar} --target_provided=${target_provided} -t=${t} + +cleanup: mtar +# Remove tmp folder + @$(MBT) clean -t=${t} \ No newline at end of file diff --git a/multitenancy/app/package.json b/multitenancy/app/package.json new file mode 100644 index 00000000..334c0fdb --- /dev/null +++ b/multitenancy/app/package.json @@ -0,0 +1,19 @@ +{ + "name": "approuter", + "version": "1.0.0", + "description": "", + "main": "index.js", + "devDependencies": {}, + "engines": { + "node": "^12.0.0" + }, + "scripts": { + "start": "node node_modules/@sap/approuter/approuter.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@sap/approuter": ">=9.0.2" + } +} diff --git a/multitenancy/app/services.cds b/multitenancy/app/services.cds index 95368e3d..ea0e3019 100644 --- a/multitenancy/app/services.cds +++ b/multitenancy/app/services.cds @@ -4,9 +4,8 @@ using from './admin/fiori-service'; using from './browse/fiori-service'; +using from './orders/fiori-service'; using from './common'; using from '../db/capire_common'; -// only works in case of embedded orders service -// using from './orders/app/orders/fiori-service'; diff --git a/multitenancy/app/xs-app.json b/multitenancy/app/xs-app.json new file mode 100644 index 00000000..763f0ec3 --- /dev/null +++ b/multitenancy/app/xs-app.json @@ -0,0 +1,28 @@ +{ + "welcomeFile": "/admin-fiori.html", + "authenticationMethod": "route", + "sessionTimeout": 30, + "logout": { + "logoutEndpoint": "/do/logout", + "logoutPage": "/" + }, + "routes": [ + { + "source": "^/((admin|browse|orders)/webapp/.*)$", + "target": "$1", + "localDir": ".", + "authenticationType": "xsuaa" + }, + { + "source": "^(/[^/]+\\.html(\\?.*)?)$", + "target": "$1", + "localDir": ".", + "authenticationType": "xsuaa" + }, + { + "source": "^.*$", + "destination": "srv-api", + "authenticationType": "xsuaa" + } + ] +} diff --git a/multitenancy/db/data/sap.common-Countries_texts.csv b/multitenancy/db/data/sap.common-Countries_texts._csv similarity index 100% rename from multitenancy/db/data/sap.common-Countries_texts.csv rename to multitenancy/db/data/sap.common-Countries_texts._csv diff --git a/multitenancy/db/data/sap.common-Currencies_texts.csv b/multitenancy/db/data/sap.common-Currencies_texts._csv similarity index 100% rename from multitenancy/db/data/sap.common-Currencies_texts.csv rename to multitenancy/db/data/sap.common-Currencies_texts._csv diff --git a/multitenancy/db/data/sap.common-Languages.csv b/multitenancy/db/data/sap.common-Languages._csv similarity index 100% rename from multitenancy/db/data/sap.common-Languages.csv rename to multitenancy/db/data/sap.common-Languages._csv diff --git a/multitenancy/db/data/sap.common-Languages_texts.csv b/multitenancy/db/data/sap.common-Languages_texts._csv similarity index 100% rename from multitenancy/db/data/sap.common-Languages_texts.csv rename to multitenancy/db/data/sap.common-Languages_texts._csv diff --git a/multitenancy/db/schema.cds b/multitenancy/db/schema.cds index aac1fe1d..2b16a683 100644 --- a/multitenancy/db/schema.cds +++ b/multitenancy/db/schema.cds @@ -1,3 +1,4 @@ using from './schema_bookshop'; using from './schema_orders'; +annotate cds.UUID with @(Core.Computed : true); diff --git a/multitenancy/map-route.sh b/multitenancy/map-route.sh new file mode 100755 index 00000000..3d899869 --- /dev/null +++ b/multitenancy/map-route.sh @@ -0,0 +1,8 @@ +#!/bin/bash + + +SUBDOMAIN=mtx-extend-bookshop +SAAS_HOST_SUFFIX="$(cf env multitenancy-approuter | grep TENANT_HOST_PATTERN | sed 's/.*(..)//' | sed 's/\..*//')" +SAAS_DOMAIN="$(cf env multitenancy-approuter | grep TENANT_HOST_PATTERN | sed 's/.*(..)//' | sed 's/[^.]*\.//')" + +cf map-route multitenancy-approuter $SAAS_DOMAIN --hostname $SUBDOMAIN$SAAS_HOST_SUFFIX \ No newline at end of file diff --git a/multitenancy/mta.yaml b/multitenancy/mta.yaml index b2915803..c1b08d8e 100644 --- a/multitenancy/mta.yaml +++ b/multitenancy/mta.yaml @@ -8,7 +8,7 @@ version: 1.0.0 description: "A simple CAP project." parameters: enable-parallel-deployments: true - + build-parameters: before-all: - builder: custom @@ -17,6 +17,26 @@ build-parameters: - npx -p @sap/cds-dk cds build --production modules: + + - name: multitenancy-approuter + type: nodejs + path: app + parameters: + # Keep existing URLs for this application ("routes") + keep-existing-routes: true + properties: + TENANT_HOST_PATTERN: "^(.*)-${default-host}.${default-domain}" + requires: + - name: multitenancy-registry + - name: multitenancy-uaa-mt + - name: srv-api + group: destinations + properties: + forwardAuthToken: true + strictSSL: true + name: srv-api + url: ~{srv-url} + # --------------------- SERVER MODULE ------------------------ - name: multitenancy-srv # ------------------------------------------------------------ @@ -57,7 +77,7 @@ resources: type: org.cloudfoundry.managed-service parameters: service: xsuaa - service-plan: application + service-plan: application path: ./xs-security.json config: xsappname: multitenancy-${space} # name + space dependency @@ -67,11 +87,11 @@ resources: type: org.cloudfoundry.managed-service requires: - name: multitenancy-uaa-mt - - name: mtx-api - properties: - prop: ~{mtx-url} - parameters: - param: ~{mtx-url} + - name: mtx-api + properties: + prop: ~{mtx-url} + parameters: + param: ~{mtx-url} parameters: service: saas-registry service-plan: application diff --git a/multitenancy/package.json b/multitenancy/package.json index 0644c12c..0939ab11 100644 --- a/multitenancy/package.json +++ b/multitenancy/package.json @@ -48,36 +48,38 @@ } }, "cds": { - "requires": { - "multitenancy": true, - "auth": { - "strategy": "JWT" - }, - "db": { - "kind": "hana", - "vcap": { - "label": "service-manager" + "[production]": { + "requires": { + "multitenancy": true, + "auth": { + "strategy": "JWT" + }, + "db": { + "kind": "hana", + "vcap": { + "label": "service-manager" + } + }, + "uaa": { + "kind": "xsuaa" } }, - "uaa": { - "kind": "xsuaa" - } - }, - "hana": { - "deploy-format": "hdbtable" - }, - "mtx": { - "element-prefix": "Z_", - "namespace-blacklist": [ - "com.sap.", - "sap." - ], - "entity-whitelist": [], - "service-whitelist": [] - }, - "auth": { - "passport": { - "strategy": "JWT" + "hana": { + "deploy-format": "hdbtable" + }, + "mtx": { + "element-prefix": "Z_", + "namespace-blacklist": [ + "com.sap.", + "sap." + ], + "entity-whitelist": [], + "service-whitelist": [] + }, + "auth": { + "passport": { + "strategy": "JWT" + } } } }