Compare commits
25 Commits
Reuse-Migr
...
shared-db-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2c3e57e38 | ||
|
|
d79fbde2de | ||
|
|
a657be4adc | ||
|
|
d713b45596 | ||
|
|
e2901a9f60 | ||
|
|
1646ab5e13 | ||
|
|
8332be13e1 | ||
|
|
e22e1b0d12 | ||
|
|
70d7e6ffea | ||
|
|
89307140ad | ||
|
|
39335c8c9b | ||
|
|
dca837e595 | ||
|
|
7686931f56 | ||
|
|
e648b0072a | ||
|
|
49ca54ca82 | ||
|
|
24154725ba | ||
|
|
745698fe12 | ||
|
|
ac4154eef3 | ||
|
|
49a4dfc988 | ||
|
|
af3e905866 | ||
|
|
aee2f35327 | ||
|
|
bbaaefae5b | ||
|
|
c1dbe94c64 | ||
|
|
5e161d1564 | ||
|
|
7536a30313 |
29
.reuse/dep5
Normal file
29
.reuse/dep5
Normal file
@@ -0,0 +1,29 @@
|
||||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: cloud-cap-samples
|
||||
Upstream-Contact: <Christian Georgi (christian.georgi@sap.com)>
|
||||
Source: https://github.com/SAP-samples/cloud-cap-samples
|
||||
Disclaimer: The code in this project may include calls to APIs (“API Calls”) of
|
||||
SAP or third-party products or services developed outside of this project
|
||||
(“External Products”).
|
||||
“APIs” means application programming interfaces, as well as their respective
|
||||
specifications and implementing code that allows software to communicate with
|
||||
other software.
|
||||
API Calls to External Products are not licensed under the open source license
|
||||
that governs this project. The use of such API Calls and related External
|
||||
Products are subject to applicable additional agreements with the relevant
|
||||
provider of the External Products. In no event shall the open source license
|
||||
that governs this project grant any rights in or to any External Products,or
|
||||
alter, expand or supersede any terms of the applicable additional agreements.
|
||||
If you have a valid license agreement with SAP for the use of a particular SAP
|
||||
External Product, then you may make use of any API Calls included in this
|
||||
project’s code for that SAP External Product, subject to the terms of such
|
||||
license agreement. If you do not have a valid license agreement for the use of
|
||||
a particular SAP External Product, then you may only make use of any API Calls
|
||||
in this project for that SAP External Product for your internal, non-productive
|
||||
and non-commercial test and evaluation of such API Calls. Nothing herein grants
|
||||
you any rights to use or access any SAP External Product, or provide any third
|
||||
parties the right to use of access any SAP External Product, through API Calls.
|
||||
|
||||
Files: *.*
|
||||
Copyright: 2019-2025 SAP SE or an SAP affiliate company and cap-cloud-samples
|
||||
License: Apache-2.0
|
||||
11
README.md
11
README.md
@@ -1,4 +1,3 @@
|
||||
[](https://api.reuse.software/info/github.com/SAP-samples/cloud-cap-samples)
|
||||
|
||||
|
||||
# Welcome to cap/samples
|
||||
@@ -10,20 +9,12 @@ Find here a collection of samples for the [SAP Cloud Application Programming Mod
|
||||

|
||||
|
||||

|
||||
[](https://api.reuse.software/info/github.com/SAP-samples/cloud-cap-samples)
|
||||
|
||||
|
||||
|
||||
### Preliminaries
|
||||
|
||||
1. Ensure you have the latest LTS version of Node.js installed (see [Getting Started](https://cap.cloud.sap/docs/get-started/jumpstart))
|
||||
2. Install [**@sap/cds-dk**](https://cap.cloud.sap/docs/get-started/) globally:
|
||||
|
||||
```sh
|
||||
npm i -g @sap/cds-dk
|
||||
```
|
||||
|
||||
3. _Optional:_ [Use Visual Studio Code](https://cap.cloud.sap/docs/get-started/tools#vscode)
|
||||
Ensure you have the latest LTS version of Node.js, [`@sap/cds-dk`](https://www.npmjs.com/package/@sap/cds-dk) installed globally, `git` and your IDE ready (see [Initial Setup](https://cap.cloud.sap/docs/get-started/#setup))
|
||||
|
||||
### Download
|
||||
|
||||
|
||||
11
REUSE.toml
11
REUSE.toml
@@ -1,11 +0,0 @@
|
||||
version = 1
|
||||
SPDX-PackageName = "cloud-cap-samples"
|
||||
SPDX-PackageSupplier = "<CAP (cap@sap.com)>"
|
||||
SPDX-PackageDownloadLocation = "https://github.com/SAP-samples/cloud-cap-samples"
|
||||
SPDX-PackageComment = "The code in this project may include calls to APIs (“API Calls”) of\n SAP or third-party products or services developed outside of this project\n (“External Products”).\n “APIs” means application programming interfaces, as well as their respective\n specifications and implementing code that allows software to communicate with\n other software.\n API Calls to External Products are not licensed under the open source license\n that governs this project. The use of such API Calls and related External\n Products are subject to applicable additional agreements with the relevant\n provider of the External Products. In no event shall the open source license\n that governs this project grant any rights in or to any External Products,or\n alter, expand or supersede any terms of the applicable additional agreements.\n If you have a valid license agreement with SAP for the use of a particular SAP\n External Product, then you may make use of any API Calls included in this\n project’s code for that SAP External Product, subject to the terms of such\n license agreement. If you do not have a valid license agreement for the use of\n a particular SAP External Product, then you may only make use of any API Calls\n in this project for that SAP External Product for your internal, non-productive\n and non-commercial test and evaluation of such API Calls. Nothing herein grants\n you any rights to use or access any SAP External Product, or provide any third\n parties the right to use of access any SAP External Product, through API Calls."
|
||||
|
||||
[[annotations]]
|
||||
path = "**.**"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2019-2025 SAP SE or an SAP affiliate company and cap-cloud-samples"
|
||||
SPDX-License-Identifier = "Apache-2.0"
|
||||
1
app/router/bookshop
Symbolic link
1
app/router/bookshop
Symbolic link
@@ -0,0 +1 @@
|
||||
../../bookshop/app/vue
|
||||
1
app/router/orders
Symbolic link
1
app/router/orders
Symbolic link
@@ -0,0 +1 @@
|
||||
../../orders/app/orders
|
||||
2427
app/router/package-lock.json
generated
Normal file
2427
app/router/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
app/router/package.json
Normal file
12
app/router/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "approuter",
|
||||
"dependencies": {
|
||||
"@sap/approuter": "^19.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node node_modules/@sap/approuter/approuter.js"
|
||||
}
|
||||
}
|
||||
1
app/router/reviews
Symbolic link
1
app/router/reviews
Symbolic link
@@ -0,0 +1 @@
|
||||
../../reviews/app/vue
|
||||
52
app/router/xs-app.json
Normal file
52
app/router/xs-app.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"welcomeFile": "app/bookshop/index.html",
|
||||
"routes": [
|
||||
{
|
||||
"source": "^/app/(.*)$",
|
||||
"target": "$1",
|
||||
"localDir": ".",
|
||||
"cacheControl": "no-cache, no-store, must-revalidate"
|
||||
},
|
||||
{
|
||||
"source": "^/appconfig/",
|
||||
"localDir": ".",
|
||||
"cacheControl": "no-cache, no-store, must-revalidate"
|
||||
},
|
||||
{
|
||||
"source": "^/admin/(.*)$",
|
||||
"target": "/admin/$1",
|
||||
"destination": "bookstore-api",
|
||||
"csrfProtection": true
|
||||
},
|
||||
{
|
||||
"source": "^/browse/(.*)$",
|
||||
"target": "/browse/$1",
|
||||
"destination": "bookstore-api",
|
||||
"csrfProtection": true
|
||||
},
|
||||
{
|
||||
"source": "^/user/(.*)$",
|
||||
"target": "/user/$1",
|
||||
"destination": "bookstore-api",
|
||||
"csrfProtection": true
|
||||
},
|
||||
{
|
||||
"source": "^/odata/v4/orders/(.*)$",
|
||||
"target": "/odata/v4/orders/$1",
|
||||
"destination": "orders-api",
|
||||
"csrfProtection": true
|
||||
},
|
||||
{
|
||||
"source": "^/reviews/(.*)$",
|
||||
"target": "/reviews/$1",
|
||||
"destination": "reviews-api",
|
||||
"csrfProtection": true
|
||||
},
|
||||
{
|
||||
"source": "^(.*)$",
|
||||
"target": "$1",
|
||||
"localDir": ".",
|
||||
"cacheControl": "no-cache, no-store, must-revalidate"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,14 +2,21 @@
|
||||
"name": "@capire/bookstore",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@cap-js/hana": "^1.7.0",
|
||||
"@capire/bookshop": "*",
|
||||
"@capire/reviews": "*",
|
||||
"@capire/orders": "*",
|
||||
"@capire/common": "*",
|
||||
"@capire/data-viewer": "*",
|
||||
"@capire/orders": "*",
|
||||
"@capire/reviews": "*",
|
||||
"@sap-cloud-sdk/http-client": "^3.26.4",
|
||||
"@sap-cloud-sdk/resilience": "^3.26.4",
|
||||
"@sap/cds": ">=5",
|
||||
"@sap/xssec": "^4.4.0",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds-serve"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"ReviewsService": {
|
||||
@@ -20,15 +27,13 @@
|
||||
"kind": "odata",
|
||||
"model": "@capire/orders"
|
||||
},
|
||||
"messaging": {
|
||||
"[development]": { "kind": "file-based-messaging" },
|
||||
"[hybrid]": { "kind": "enterprise-messaging-shared" },
|
||||
"[production]": { "kind": "enterprise-messaging" }
|
||||
},
|
||||
"messaging": true,
|
||||
"db": {
|
||||
"kind": "sql"
|
||||
}
|
||||
},
|
||||
"log": { "service": true }
|
||||
"log": {
|
||||
"service": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ module.exports = async()=>{ // called by server.js
|
||||
CatalogService.on ('OrderedBook', async (msg) => {
|
||||
const { book, quantity, buyer } = msg.data
|
||||
const { title, price } = await db.read (Books, book, b => { b.title, b.price })
|
||||
return OrdersService.create ('Orders').entries({
|
||||
return OrdersService.create ('OrdersNoDraft').entries({
|
||||
OrderNo: 'Order at '+ (new Date).toLocaleString(),
|
||||
Items: [{ product:{ID:`${book}`}, title, price, quantity }],
|
||||
buyer, createdBy: buyer
|
||||
|
||||
@@ -34,7 +34,8 @@ class DataService extends cds.ApplicationService { init(){
|
||||
query.SELECT.limit = req.query.SELECT.limit // forward $skip / $top
|
||||
|
||||
const dataSource = findDataSource(dataSourceName, entityName)
|
||||
const res = await dataSource.run(query)
|
||||
let res = await dataSource.run(query)
|
||||
if (!Array.isArray(res)) res = [res] // singleton result
|
||||
return res.map((line) => {
|
||||
const record = Object.entries(line).map(([column, data]) => ({ column, data }))
|
||||
return {
|
||||
29
event-mesh.json
Normal file
29
event-mesh.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"version": "1.1.0",
|
||||
"options": {
|
||||
"management": true,
|
||||
"messagingrest": true,
|
||||
"messaging": true
|
||||
},
|
||||
"rules": {
|
||||
"topicRules": {
|
||||
"publishFilter": [
|
||||
"*"
|
||||
],
|
||||
"subscribeFilter": [
|
||||
"*"
|
||||
]
|
||||
},
|
||||
"queueRules": {
|
||||
"publishFilter": [
|
||||
"*"
|
||||
],
|
||||
"subscribeFilter": [
|
||||
"*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"authorities": [
|
||||
"$ACCEPT_GRANTED_AUTHORITIES"
|
||||
]
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
# Hello World Getting Started Sample
|
||||
|
||||
## Next Steps
|
||||
|
||||
- To run the JavaScript implementation, open a new terminal and run `cds watch`.
|
||||
- To run the TypeScript implementation, open a new terminal and run `cds-ts watch`.
|
||||
|
||||
Then call the service at: http://localhost:4004/say/hello(to='world')
|
||||
|
||||
## Learn More
|
||||
|
||||
Learn more about:
|
||||
|
||||
- [Hello World!](https://cap.cloud.sap/docs/get-started/hello-world)
|
||||
- [Using TypeScript](https://cap.cloud.sap/docs/node.js/typescript)
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "@capire/hello-world",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"test": "npx jest --silent",
|
||||
"start": "cds-serve srv/world.cds",
|
||||
"start:ts": "cds-ts serve srv/world.cds"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=5.0.4"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
service say {
|
||||
function hello (to:String) returns String;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
module.exports = class say {
|
||||
hello(req) {
|
||||
let {to} = req.data
|
||||
if (to === 'me') to = require('os').userInfo().username
|
||||
return `Hello ${to}!`
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { Request } from "@sap/cds"
|
||||
|
||||
module.exports = class say {
|
||||
hello(req: Request) {
|
||||
return `Hello ${req.data.to} from a TypeScript file!`
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
GET http://localhost:4004/odata/v4/say/hello
|
||||
###
|
||||
|
||||
GET http://localhost:4004/odata/v4/say/hello(to='me')
|
||||
###
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace sap.capire.media;
|
||||
|
||||
entity Media {
|
||||
|
||||
key id:Integer;
|
||||
@Core.MediaType: mediaType
|
||||
content : LargeBinary ;
|
||||
|
||||
@Core.IsMediaType: true
|
||||
mediaType : String;
|
||||
fileName : String;
|
||||
applicationName:String;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
using from './db/data-model';
|
||||
using from './srv/media-service';
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "@capire/media",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"lokijs": "^1.5.6"
|
||||
},
|
||||
"files": [
|
||||
"db",
|
||||
"srv",
|
||||
"index.cds"
|
||||
],
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": {
|
||||
"kind": "sql"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using { sap.capire.media as db } from '../db/data-model';
|
||||
namespace sap.capire.media;
|
||||
|
||||
@path: '/media-server'
|
||||
service MediaServer {
|
||||
entity Media as projection on db.Media ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
const loki = require('lokijs')
|
||||
const db = new loki('DB')
|
||||
const mediaDB = db.addCollection('Media')
|
||||
const { Readable, PassThrough } = require('stream')
|
||||
|
||||
module.exports = srv => {
|
||||
srv.before('CREATE', 'Media', req => {
|
||||
const obj = mediaDB.insert({ media: '' })
|
||||
req.data.id = obj.$loki
|
||||
})
|
||||
|
||||
srv.on('UPDATE', 'Media', (req, next) => {
|
||||
const url = req.path
|
||||
if (url.includes('content')) {
|
||||
const id = req.data.id
|
||||
const obj = mediaDB.get(id)
|
||||
if (!obj) {
|
||||
req.reject(404, 'No record found for the ID')
|
||||
return
|
||||
}
|
||||
const stream = new PassThrough()
|
||||
const chunks = []
|
||||
stream.on('data', chunk => {
|
||||
chunks.push(chunk)
|
||||
})
|
||||
stream.on('end', () => {
|
||||
obj.media = Buffer.concat(chunks).toString('base64')
|
||||
mediaDB.update(obj)
|
||||
})
|
||||
req.data.content.pipe(stream)
|
||||
} else return next()
|
||||
})
|
||||
|
||||
srv.on('READ', 'Media', (req, next) => {
|
||||
const url = req.path
|
||||
if (url.includes('content')) {
|
||||
const id = req.data.id
|
||||
const mediaObj = mediaDB.get(id)
|
||||
if (!mediaObj) {
|
||||
req.reject(404, 'Media not found for the ID')
|
||||
return
|
||||
}
|
||||
const decodedMedia = Buffer.from(
|
||||
mediaObj.media.split(';base64,').pop(),
|
||||
'base64'
|
||||
)
|
||||
return _formatResult(decodedMedia)
|
||||
} else return next() //> delegate to next/default handlers
|
||||
})
|
||||
|
||||
srv.on('DELETE', 'Media', (req, next) => {
|
||||
const id = req.data.id
|
||||
mediaDB
|
||||
.chain()
|
||||
.find({ $loki: id })
|
||||
.remove()
|
||||
return next() //> delegate to next/default handlers
|
||||
})
|
||||
|
||||
function _formatResult (decodedMedia) {
|
||||
const readable = new Readable()
|
||||
const result = new Array()
|
||||
readable.push(decodedMedia)
|
||||
readable.push(null)
|
||||
result.push({ value: readable })
|
||||
return result
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB |
@@ -1,35 +0,0 @@
|
||||
### Requires REST Client for VS Code
|
||||
### https://marketplace.visualstudio.com/items?itemName=humao.rest-client
|
||||
###
|
||||
@protocol = http
|
||||
@host = localhost
|
||||
@port = 4004
|
||||
### Read Pictures
|
||||
GET {{protocol}}://{{host}}:{{port}}/media-server/Media
|
||||
Authorization: Basic admin:
|
||||
|
||||
### Create Picture with mediatype
|
||||
POST {{protocol}}://{{host}}:{{port}}/media-server/Media
|
||||
Authorization: Basic admin:
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"mediaType": "image/png"
|
||||
}
|
||||
|
||||
### Upload Binary PNG
|
||||
PUT {{protocol}}://{{host}}:{{port}}/media-server/Media(1)/content
|
||||
Authorization: Basic admin:
|
||||
Content-Type: image/png
|
||||
|
||||
< ./Test.png
|
||||
|
||||
### Read Binary
|
||||
GET {{protocol}}://{{host}}:{{port}}/media-server/Media(1)/content
|
||||
Authorization: Basic admin:
|
||||
|
||||
### Delete Image
|
||||
DELETE {{protocol}}://{{host}}:{{port}}/media-server/Media(1)
|
||||
Authorization: Basic admin:
|
||||
177
mta.yaml
Normal file
177
mta.yaml
Normal file
@@ -0,0 +1,177 @@
|
||||
_schema-version: 3.3.0
|
||||
ID: capire.samples
|
||||
version: 3.0.0
|
||||
description: "A monorepo with several samples for CAP."
|
||||
parameters:
|
||||
enable-parallel-deployments: true
|
||||
build-parameters:
|
||||
before-all:
|
||||
- builder: custom
|
||||
commands:
|
||||
- npm ci
|
||||
- npx cds build ./shared-db --for hana --production
|
||||
- npx cds build ./orders --for nodejs --production --ws-pack
|
||||
- npx cds build ./reviews --for nodejs --production
|
||||
- npx cds build ./bookstore --for nodejs --production --ws-pack
|
||||
modules:
|
||||
- name: bookstore-srv
|
||||
type: nodejs
|
||||
path: bookstore/gen/srv
|
||||
parameters:
|
||||
instances: 1
|
||||
buildpack: nodejs_buildpack
|
||||
build-parameters:
|
||||
builder: npm
|
||||
properties:
|
||||
cds_requires_ReviewsService_credentials: {"destination": "reviews-dest","path": "/reviews"}
|
||||
cds_requires_OrdersService_credentials: {"destination": "orders-dest","path": "/odata/v4/orders"}
|
||||
provides:
|
||||
- name: bookstore-api # required by consumers of CAP services (e.g. approuter)
|
||||
properties:
|
||||
srv-url: ${default-url}
|
||||
requires:
|
||||
- name: samples-db
|
||||
- name: samples-auth
|
||||
- name: samples-messaging
|
||||
- name: samples-destination
|
||||
|
||||
- name: orders-srv
|
||||
type: nodejs
|
||||
path: orders/gen/srv
|
||||
parameters:
|
||||
instances: 1
|
||||
buildpack: nodejs_buildpack
|
||||
build-parameters:
|
||||
builder: npm
|
||||
provides:
|
||||
- name: orders-api # required by consumers of CAP services (e.g. approuter)
|
||||
properties:
|
||||
srv-url: ${default-url}
|
||||
requires:
|
||||
- name: samples-db
|
||||
- name: samples-auth
|
||||
- name: samples-messaging
|
||||
- name: samples-destination
|
||||
|
||||
- name: reviews-srv
|
||||
type: nodejs
|
||||
path: reviews/gen/srv
|
||||
parameters:
|
||||
instances: 1
|
||||
buildpack: nodejs_buildpack
|
||||
build-parameters:
|
||||
builder: npm
|
||||
provides:
|
||||
- name: reviews-api # required by consumers of CAP services (e.g. approuter)
|
||||
properties:
|
||||
srv-url: ${default-url}
|
||||
requires:
|
||||
- name: samples-db
|
||||
- name: samples-auth
|
||||
- name: samples-messaging
|
||||
- name: samples-destination
|
||||
|
||||
- name: samples-db-deployer
|
||||
type: hdb
|
||||
path: shared-db/gen/db
|
||||
parameters:
|
||||
buildpack: nodejs_buildpack
|
||||
requires:
|
||||
- name: samples-db
|
||||
|
||||
- name: samples
|
||||
type: approuter.nodejs
|
||||
path: app/router
|
||||
parameters:
|
||||
keep-existing-routes: true
|
||||
disk-quota: 256M
|
||||
memory: 256M
|
||||
requires:
|
||||
- name: orders-api
|
||||
group: destinations
|
||||
properties:
|
||||
name: orders-api
|
||||
url: ~{srv-url}
|
||||
forwardAuthToken: true
|
||||
- name: reviews-api
|
||||
group: destinations
|
||||
properties:
|
||||
name: reviews-api
|
||||
url: ~{srv-url}
|
||||
forwardAuthToken: true
|
||||
- name: bookstore-api
|
||||
group: destinations
|
||||
properties:
|
||||
name: bookstore-api
|
||||
url: ~{srv-url}
|
||||
forwardAuthToken: true
|
||||
- name: samples-auth
|
||||
- name: samples-destination
|
||||
provides:
|
||||
- name: app-api
|
||||
properties:
|
||||
app-protocol: ${protocol}
|
||||
app-uri: ${default-uri}
|
||||
|
||||
- name: destination-content
|
||||
type: com.sap.application.content
|
||||
requires:
|
||||
- name: orders-api
|
||||
- name: reviews-api
|
||||
- name: bookstore-api
|
||||
- name: samples-auth
|
||||
parameters:
|
||||
service-key:
|
||||
name: xsuaa_service-key
|
||||
- name: samples-destination
|
||||
parameters:
|
||||
content-target: true
|
||||
build-parameters:
|
||||
no-source: true
|
||||
parameters:
|
||||
content:
|
||||
instance:
|
||||
existing_destinations_policy: update
|
||||
destinations:
|
||||
- Name: orders-dest
|
||||
URL: ~{orders-api/srv-url}
|
||||
Authentication: OAuth2ClientCredentials
|
||||
TokenServiceInstanceName: samples-auth
|
||||
TokenServiceKeyName: xsuaa_service-key
|
||||
- Name: reviews-dest
|
||||
URL: ~{reviews-api/srv-url}
|
||||
Authentication: OAuth2ClientCredentials
|
||||
TokenServiceInstanceName: samples-auth
|
||||
TokenServiceKeyName: xsuaa_service-key
|
||||
|
||||
resources:
|
||||
- name: samples-db
|
||||
type: com.sap.xs.hdi-container
|
||||
parameters:
|
||||
service: hana
|
||||
service-plan: hdi-shared
|
||||
- name: samples-auth
|
||||
type: org.cloudfoundry.managed-service
|
||||
processed-after:
|
||||
- samples-messaging
|
||||
parameters:
|
||||
service: xsuaa
|
||||
service-plan: application
|
||||
path: ./xs-security.json
|
||||
config:
|
||||
xsappname: samples-${org}-${space}
|
||||
tenant-mode: dedicated
|
||||
- name: samples-messaging
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: enterprise-messaging
|
||||
service-plan: default
|
||||
path: ./event-mesh.json
|
||||
config:
|
||||
emname: bookstore-${org}-${space}
|
||||
namespace: cap/samples/${space}
|
||||
- name: samples-destination
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
service: destination
|
||||
service-plan: lite
|
||||
@@ -2,7 +2,18 @@
|
||||
"name": "@capire/orders",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@cap-js/hana": "^1.7.0",
|
||||
"@capire/common": "*",
|
||||
"@sap/cds": ">=5"
|
||||
"@sap/cds": ">=5",
|
||||
"@sap/xssec": "^4.4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds-serve"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"messaging": true,
|
||||
"db": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,14 @@ using { sap.capire.orders as my } from '../db/schema';
|
||||
|
||||
service OrdersService {
|
||||
entity Orders as projection on my.Orders;
|
||||
|
||||
event OrderChanged {
|
||||
product: String;
|
||||
deltaQuantity: Integer;
|
||||
}
|
||||
|
||||
@odata.draft.bypass
|
||||
@(requires: 'system-user')
|
||||
entity OrdersNoDraft as projection on my.Orders;
|
||||
|
||||
}
|
||||
|
||||
7045
package-lock.json
generated
7045
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
45
package.json
45
package.json
@@ -1,45 +1,42 @@
|
||||
{
|
||||
"name": "@capire/samples",
|
||||
"version": "2.1.0",
|
||||
"version": "3.0.0",
|
||||
"description": "A monorepo with several samples for CAP.",
|
||||
"repository": "https://github.com/sap-samples/cloud-cap-samples.git",
|
||||
"author": "daniel.hutzel@sap.com",
|
||||
"dependencies": {
|
||||
"@sap/cds": ">=8"
|
||||
"@sap/cds": ">=8",
|
||||
"@cap-js/hana": "^1",
|
||||
"@sap/xssec": "^4"
|
||||
},
|
||||
"workspaces": [
|
||||
"./bookshop",
|
||||
"./bookstore",
|
||||
"./common",
|
||||
"./data-viewer",
|
||||
"./fiori",
|
||||
"./hello",
|
||||
"./media",
|
||||
"./orders",
|
||||
"./loggers",
|
||||
"./reviews"
|
||||
"./reviews",
|
||||
"./etc/data-viewer",
|
||||
"./etc/loggers"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@cap-js/cds-test": "^0",
|
||||
"@cap-js/cds-types": "^0",
|
||||
"@cap-js/sqlite": "^1",
|
||||
"axios": "^1",
|
||||
"chai": "^4.3.4",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-subset": "^1.6.0",
|
||||
"@sap/cds-dk": "^8",
|
||||
"eslint": "^9",
|
||||
"semver": "^7"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "mbt build -t gen --mtar mta.tar",
|
||||
"deploy": "cf deploy gen/mta.tar",
|
||||
"undeploy": "cf undeploy capire.samples --delete-services --delete-service-keys",
|
||||
"bookshop": "cds watch bookshop",
|
||||
"start": "cds watch fiori",
|
||||
"fiori": "cds watch fiori",
|
||||
"hello": "cds watch hello",
|
||||
"media": "cds watch media",
|
||||
"lint": "eslint",
|
||||
"test": "npx jest --silent",
|
||||
"jest": "npx jest --silent",
|
||||
"mocha": "CDS_TEST_SILENT=y npx mocha",
|
||||
"test:hello": "cd hello && npm test"
|
||||
"mocha": "CDS_TEST_SILENT=y npx mocha"
|
||||
},
|
||||
"mocha": {
|
||||
"recursive": true,
|
||||
@@ -47,5 +44,19 @@
|
||||
"timeout": 6666
|
||||
},
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"private": true
|
||||
"private": true,
|
||||
"cds": {
|
||||
"sql": {
|
||||
"native_hana_associations": false
|
||||
},
|
||||
"requires": {
|
||||
"[production]": {
|
||||
"auth": "xsuaa"
|
||||
},
|
||||
"messaging": {
|
||||
"kind": "enterprise-messaging"
|
||||
},
|
||||
"destinations": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
subject;rating;reviewer;title;text
|
||||
201;5;bob;Intriguing;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
201;4;bob;Fascinating;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id diam maecenas ultricies mi eget mauris pharetra et. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque. Pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci eu. Nec sagittis aliquam malesuada bibendum arcu. Eu consequat ac felis donec. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Tortor posuere ac ut consequat semper viverra nam libero. Amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor. Scelerisque purus semper eget duis at tellus. Elementum tempus egestas sed sed risus pretium. Arcu dictum varius duis at. Amet luctus venenatis lectus magna fringilla urna. Eget velit aliquet sagittis id consectetur purus ut faucibus. Vitae auctor eu augue ut lectus. Fermentum iaculis eu non diam phasellus vestibulum.
|
||||
207;2;bob;What is this?;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Libero justo laoreet sit amet cursus sit amet dictum. Nunc faucibus a pellentesque sit. Dis parturient montes nascetur ridiculus mus mauris vitae ultricies. Enim nunc faucibus a pellentesque. Commodo quis imperdiet massa tincidunt nunc pulvinar sapien. Cras ornare arcu dui vivamus. Facilisi etiam dignissim diam quis enim lobortis. Et molestie ac feugiat sed. Urna neque viverra justo nec ultrices dui. Ullamcorper a lacus vestibulum sed arcu non. Volutpat ac tincidunt vitae semper quis. Dignissim sodales ut eu sem. Feugiat in fermentum posuere urna nec. At augue eget arcu dictum varius.
|
||||
251;3;bob;It's dark...;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suscipit tellus mauris a diam. Velit aliquet sagittis id consectetur purus ut. Viverra adipiscing at in tellus integer. Vitae elementum curabitur vitae nunc. Mattis ullamcorper velit sed ullamcorper morbi. Diam quis enim lobortis scelerisque. Auctor neque vitae tempus quam pellentesque nec nam aliquam. Semper auctor neque vitae tempus. Quis eleifend quam adipiscing vitae proin. Neque convallis a cras semper auctor neque vitae. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Sit amet consectetur adipiscing elit ut aliquam purus. Pretium quam vulputate dignissim suspendisse.
|
||||
ID;subject;rating;reviewer;title;text
|
||||
1689144d-3b10-4849-bcbe-2408a13e161a;201;5;bob;Intriguing;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
1689144d-3b10-4849-bcbe-2408a13e161b;201;4;bob;Fascinating;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id diam maecenas ultricies mi eget mauris pharetra et. Risus at ultrices mi tempus imperdiet nulla malesuada pellentesque. Pulvinar mattis nunc sed blandit libero. Facilisis magna etiam tempor orci eu. Nec sagittis aliquam malesuada bibendum arcu. Eu consequat ac felis donec. Ultricies tristique nulla aliquet enim tortor at auctor urna nunc. Tortor posuere ac ut consequat semper viverra nam libero. Amet nisl suscipit adipiscing bibendum est ultricies integer quis auctor. Scelerisque purus semper eget duis at tellus. Elementum tempus egestas sed sed risus pretium. Arcu dictum varius duis at. Amet luctus venenatis lectus magna fringilla urna. Eget velit aliquet sagittis id consectetur purus ut faucibus. Vitae auctor eu augue ut lectus. Fermentum iaculis eu non diam phasellus vestibulum.
|
||||
1689144d-3b10-4849-bcbe-2408a13e161c;207;2;bob;What is this?;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Libero justo laoreet sit amet cursus sit amet dictum. Nunc faucibus a pellentesque sit. Dis parturient montes nascetur ridiculus mus mauris vitae ultricies. Enim nunc faucibus a pellentesque. Commodo quis imperdiet massa tincidunt nunc pulvinar sapien. Cras ornare arcu dui vivamus. Facilisi etiam dignissim diam quis enim lobortis. Et molestie ac feugiat sed. Urna neque viverra justo nec ultrices dui. Ullamcorper a lacus vestibulum sed arcu non. Volutpat ac tincidunt vitae semper quis. Dignissim sodales ut eu sem. Feugiat in fermentum posuere urna nec. At augue eget arcu dictum varius.
|
||||
1689144d-3b10-4849-bcbe-2408a13e161d;251;3;bob;It's dark...;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suscipit tellus mauris a diam. Velit aliquet sagittis id consectetur purus ut. Viverra adipiscing at in tellus integer. Vitae elementum curabitur vitae nunc. Mattis ullamcorper velit sed ullamcorper morbi. Diam quis enim lobortis scelerisque. Auctor neque vitae tempus quam pellentesque nec nam aliquam. Semper auctor neque vitae tempus. Quis eleifend quam adipiscing vitae proin. Neque convallis a cras semper auctor neque vitae. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Sit amet consectetur adipiscing elit ut aliquam purus. Pretium quam vulputate dignissim suspendisse.
|
||||
|
@@ -7,17 +7,28 @@
|
||||
"index.cds"
|
||||
],
|
||||
"dependencies": {
|
||||
"@cap-js/hana": "^1.7.0",
|
||||
"@sap/cds": ">=5",
|
||||
"@sap/xssec": "^4.4.0",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds-serve"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"messaging": {
|
||||
"[development]": { "kind": "file-based-messaging" },
|
||||
"[hybrid]": { "kind": "enterprise-messaging-shared" },
|
||||
"[production]": { "kind": "enterprise-messaging" }
|
||||
"[development]": {
|
||||
"kind": "file-based-messaging"
|
||||
},
|
||||
"[hybrid]": {
|
||||
"kind": "enterprise-messaging-shared"
|
||||
},
|
||||
"[production]": {
|
||||
"kind": "enterprise-messaging"
|
||||
}
|
||||
},
|
||||
"db": { "kind": "sql" }
|
||||
"db": true
|
||||
}
|
||||
}
|
||||
}
|
||||
10
samples.md
10
samples.md
@@ -6,12 +6,6 @@ Each sub directory essentially is an individual npm package arranged in an [all-
|
||||

|
||||
|
||||
|
||||
## [@capire/hello-world](hello)
|
||||
|
||||
- A simplistic [Hello World](https://cap.cloud.sap/docs/get-started/hello-world) service using [CDS](https://cap.cloud.sap/docs/cds/) and [cds.services](https://cap.cloud.sap/docs/node.js/api#services-api).
|
||||
- [Typescript support](https://cap.cloud.sap/docs/node.js/typescript)
|
||||
|
||||
|
||||
## [@capire/bookshop](bookshop)
|
||||
|
||||
- [Getting Started](https://cap.cloud.sap/docs/get-started/in-a-nutshell) with CAP, briefly introducing:
|
||||
@@ -60,10 +54,10 @@ Each sub directory essentially is an individual npm package arranged in an [all-
|
||||
- [@capire/reviews](reviews)
|
||||
- [@capire/orders](orders)
|
||||
- [@capire/common](common)
|
||||
- [@capire/data-viewer](data-viewer)
|
||||
- [@capire/data-viewer](etc/data-viewer)
|
||||
- [The Vue.js app](bookshop/app/vue) imported from `bookshop` is served as well
|
||||
- [The Vue.js app](reviews/app/vue) imported from `reviews` is served as well
|
||||
- [The Vue.js app](data-viewer/app/data) imported from `data-viewer` is served as well
|
||||
- [The Vue.js app](etc/data-viewer/app/data) imported from `data-viewer` is served as well
|
||||
- [The Fiori app](orders/app) imported from `orders` is served as well
|
||||
- [OpenAPI export + Swagger UI](https://cap.cloud.sap/docs/advanced/openapi)
|
||||
|
||||
|
||||
3
shared-db/db/index.cds
Normal file
3
shared-db/db/index.cds
Normal file
@@ -0,0 +1,3 @@
|
||||
using from '@capire/bookstore';
|
||||
using from '@capire/reviews';
|
||||
using from '@capire/orders';
|
||||
17
shared-db/package.json
Normal file
17
shared-db/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "shared-db",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"cds": {
|
||||
"sql": {
|
||||
"native_hana_associations": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
describe('cap/samples - Hello world!', () => {
|
||||
|
||||
const { GET, expect } = cds.test (__dirname+'/../hello')
|
||||
|
||||
it('should say hello with class impl', async () => {
|
||||
const {data} = await GET `/odata/v4/say/hello(to='world')`
|
||||
expect(data.value).to.eql('Hello world!')
|
||||
})
|
||||
|
||||
it('should say hello with another impl', async () => {
|
||||
await cds.serve('say').from(cds.model)
|
||||
.at('/say-again').in(cds.app)
|
||||
.with(srv => {
|
||||
srv.on('hello', (req) => `Hello again ${req.data.to}!`)
|
||||
})
|
||||
const {data} = await GET `/say-again/hello(to='world')`
|
||||
expect(data.value).to.eql('Hello again world!')
|
||||
})
|
||||
|
||||
})
|
||||
34
xs-security.json
Normal file
34
xs-security.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"scopes": [
|
||||
{
|
||||
"name": "$XSAPPNAME.admin",
|
||||
"description": "admin"
|
||||
},
|
||||
{
|
||||
"name": "$XSAPPNAME.emcallback",
|
||||
"description": "Enterprise-Messaging Callback Access",
|
||||
"grant-as-authority-to-apps": [
|
||||
"$XSSERVICENAME(samples-messaging)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "$XSAPPNAME.emmanagement",
|
||||
"description": "Enterprise-Messaging Management Access"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"role-templates": [
|
||||
{
|
||||
"name": "admin",
|
||||
"scope-references": [
|
||||
"$XSAPPNAME.admin"
|
||||
],
|
||||
"description": "cap samples multi-service shared-db"
|
||||
}
|
||||
],
|
||||
"authorities-inheritance": false,
|
||||
"authorities": [
|
||||
"$XSAPPNAME.emmanagement",
|
||||
"$XSAPPNAME.mtcallback"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user