forked from SAP-samples/cloud-sdk-js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request SAP-samples#428 from SAP-samples/multi-tenat-sample
multi tenant sample
- Loading branch information
Showing
22 changed files
with
4,401 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/prettierrc", | ||
"singleQuote": true, | ||
"filepath": "*.ts", | ||
"trailingComma": "none", | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# SAP Cloud SDK for JavaScript Multi-Tenant Sample Application | ||
|
||
## Description | ||
|
||
The code sample in this directory is a reference for the [multi-tenant application tutorial](https://sap.github.io/cloud-sdk/docs/js/tutorials/multi-tenant-application). | ||
You need to make adjustments to the code before deployment. | ||
The terms you need to replace are given in all caps and start with _`YOUR_`_ e.g. _`YOUR_REGION`_. | ||
|
||
Also, note that the samples here are intended as a didactic example and are not necessarily a best practice. | ||
The repositories' structure is as follows: | ||
|
||
- [./multi-tenant-app](./multi-tenant-app) - Contains the code of the multi-tenant application. | ||
It contains a simple service endpoint and logic to be executed on subscription and unsubscription. | ||
- [./approuter](./approuter) - Contains the approuter necessary to attach JSON web tokens to the application. | ||
- [./service-config](./service-config) - Directory configurations for service instances. | ||
|
||
## Requirements | ||
|
||
The minimal requirements are: | ||
|
||
- A terminal to execute commands | ||
- A recent version of node and npm installed e.g. node 14 and npm 6 | ||
- A recent installation of the [Cloud Foundry command line interface](https://developers.sap.com/tutorials/cp-cf-download-cli.html) | ||
- An IDE or a text editor of your choice | ||
- Access to a [SAP Business Technology Platform](https://www.sap.com/products/business-technology-platform.html) account | ||
- Entitlement to use resources like service instance creation and application processing units | ||
- Permission to deploy applications and create service instances | ||
|
||
## Download and Deployment | ||
|
||
To download the application run: | ||
|
||
``` | ||
git clone \ | ||
--depth 1 \ | ||
--filter=blob:none \ | ||
--sparse \ | ||
https://github.com/SAP-samples/cloud-sdk-js.git \ | ||
; | ||
cd cloud-sdk-js | ||
git sparse-checkout set samples/cf-multi-tenant-application | ||
``` | ||
|
||
### Create Services on SAP BTP Cloud Foundry | ||
|
||
Before you can deploy the application, you have to create a `destination` and `xsuaa` service instance. | ||
Their name should match the one that is used in the application `manifest.yml`, in this case: | ||
|
||
- `destination` | ||
- `xsuaa` | ||
|
||
### Deploy the Application to SAP BTP Cloud Foundry | ||
|
||
Run `cf push` in the application directory to deploy the application. | ||
Please follow the steps described in the [multi-tenant application tutorial](https://sap.github.io/cloud-sdk/docs/js/tutorials/multi-tenant-application) for the deployment steps of all components. |
17 changes: 17 additions & 0 deletions
17
samples/cf-multi-tenant-application/approuter/manifest.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
applications: | ||
- name: approuter | ||
routes: | ||
- route: 'route-prefix-YOUR_SUBDOMAIN.cfapps.YOUR_REGION.hana.ondemand.com' | ||
path: . | ||
memory: 128M | ||
buildpacks: | ||
- nodejs_buildpack | ||
env: | ||
TENANT_HOST_PATTERN: 'route-prefix-(.*).cfapps.YOUR_REGION.hana.ondemand.com' | ||
destinations: > | ||
[ | ||
{"name":"multi-tenant-app","url":"https://multi-tenant-app.cfapps.YOUR_REGION.hana.ondemand.com","forwardAuthToken":true} | ||
] | ||
services: | ||
- xsuaa | ||
- destination |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "approuter", | ||
"dependencies": { | ||
"@sap/approuter": "latest" | ||
}, | ||
"scripts": { | ||
"start": "node node_modules/@sap/approuter/approuter.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"welcomeFile": "index.html", | ||
"routes": [ | ||
{ | ||
"source": "(.*)", | ||
"target": "/$1", | ||
"destination": "multi-tenant-app" | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
samples/cf-multi-tenant-application/multi-tenant-app/manifest.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
applications: | ||
- name: multi-tenant-app | ||
path: . | ||
memory: 256M | ||
buildpacks: | ||
- nodejs_buildpack | ||
services: | ||
- destination | ||
- xsuaa | ||
routes: | ||
- route: 'multi-tenant-app.cfapps.YOUR_REGION.hana.ondemand.com' |
Oops, something went wrong.