"Enable CF Merge branch 'OpenSAP-week3-unit5' of https://github.com/SAP-samples/cloud-cap-samples into OpenSAP-week3-unit5
This commit is contained in:
12
db/package.json
Normal file
12
db/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "deploy",
|
||||
"dependencies": {
|
||||
"@sap/hdi-deploy": "^3.8.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^8"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node node_modules/@sap/hdi-deploy/deploy.js"
|
||||
}
|
||||
}
|
||||
78
mta.yaml
Normal file
78
mta.yaml
Normal file
@@ -0,0 +1,78 @@
|
||||
####### Generated mta.yaml based on template version 0.2.0
|
||||
####### appName = capire-samples
|
||||
####### language=nodejs; multiTenant=
|
||||
####### approuter=
|
||||
|
||||
_schema-version: '3.1'
|
||||
ID: sap.capire-samples
|
||||
version: 1.0.0
|
||||
description: "The umbrella project for all samples to easily setup for local development and tests."
|
||||
|
||||
build-parameters:
|
||||
before-all:
|
||||
- builder: custom
|
||||
commands:
|
||||
- npm install
|
||||
- cds build/all
|
||||
|
||||
parameters:
|
||||
enable-parallel-deployments: true
|
||||
|
||||
modules:
|
||||
############## SERVER MODULE ##########################
|
||||
- name: capire-samples-srv
|
||||
type: nodejs
|
||||
path:
|
||||
properties:
|
||||
EXIT: 1 # required by deploy.js task to terminate
|
||||
|
||||
|
||||
requires:
|
||||
#### Resources extracted from CAP configuration ####
|
||||
- name: capire-samples-db
|
||||
- name: capire-samples-uaa
|
||||
|
||||
provides:
|
||||
- name: srv-binding # required by consumers of CAP services (e.g. approuter)
|
||||
properties:
|
||||
srv-url: ${default-url}
|
||||
|
||||
############################################################
|
||||
|
||||
############## SIDECAR MODULE #########################
|
||||
- name: db
|
||||
|
||||
type: hdb
|
||||
path: gen/db
|
||||
parameters:
|
||||
app-name: capire-samples-db
|
||||
requires:
|
||||
#### Hana and xsuaa resources extracted from CAP configuration ####
|
||||
- name: capire-samples-db
|
||||
- name: capire-samples-uaa
|
||||
############################################################
|
||||
|
||||
|
||||
############## RESOURCES ##################################
|
||||
resources:
|
||||
##### Services extracted from CAP configuration ####
|
||||
##### 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
|
||||
- name: capire-samples-db
|
||||
type: com.sap.xs.hdi-container
|
||||
|
||||
parameters:
|
||||
service: hanatrial
|
||||
properties:
|
||||
hdi-service-name: ${service-name} # required for Java case
|
||||
- name: capire-samples-uaa
|
||||
|
||||
type: org.cloudfoundry.managed-service
|
||||
parameters:
|
||||
path: ./xs-security.json
|
||||
service: xsuaa
|
||||
service-plan: application
|
||||
config:
|
||||
xsappname: capire-samples-${space} # name + space dependency
|
||||
tenant-mode: dedicated
|
||||
### scopes and role templates will be added below by a developer or by CAP tools
|
||||
############################################################
|
||||
43
package.json
43
package.json
@@ -1,4 +1,5 @@
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
"name": "@sap/capire-samples",
|
||||
"description": "The umbrella project for all samples to easily setup for local development and tests.",
|
||||
"repository": "https://github.com/SAP-samples/cloud-cap-samples.git",
|
||||
@@ -26,4 +27,46 @@
|
||||
"jest": "*"
|
||||
},
|
||||
"license": "SAP SAMPLE CODE LICENSE"
|
||||
=======
|
||||
"name": "@sap/capire-samples",
|
||||
"description": "The umbrella project for all samples to easily setup for local development and tests.",
|
||||
"repository": "https://github.com/SAP-samples/cloud-cap-samples.git",
|
||||
"author": "daniel.hutzel@sap.com",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
|
||||
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
|
||||
"cleanup": "lerna clean -y && rm -fr node_modules",
|
||||
"bookshop": "cds watch packages/bookshop",
|
||||
"bookshop-enhanced": "cds watch packages/bookshop-enhanced",
|
||||
"reviews-service": "cds watch packages/reviews-service",
|
||||
"bookstore": "cds watch packages/bookstore",
|
||||
"media-server": "cds watch packages/media-server"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": "latest",
|
||||
"express": "*",
|
||||
"passport": "^0.4.1",
|
||||
"hdb": "^0.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"sqlite3": "*"
|
||||
},
|
||||
"--add-these-to-devDependencies-for-tests": {
|
||||
"@types/jest": "*",
|
||||
"jest": "*"
|
||||
},
|
||||
"license": "SAP SAMPLE CODE LICENSE",
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": {
|
||||
"kind": "hana",
|
||||
"model": "srv"
|
||||
},
|
||||
"uaa": {
|
||||
"kind": "xsuaa"
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> cad3a32c78620f4c4558fad34991dd48866af8d3
|
||||
}
|
||||
|
||||
29
packages/bookshop/package-lock.json
generated
29
packages/bookshop/package-lock.json
generated
@@ -1,4 +1,5 @@
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
@@ -980,3 +981,31 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
=======
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"passport": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/passport/-/passport-0.4.1.tgz",
|
||||
"integrity": "sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg==",
|
||||
"requires": {
|
||||
"passport-strategy": "1.x.x",
|
||||
"pause": "0.0.1"
|
||||
}
|
||||
},
|
||||
"passport-strategy": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
|
||||
"integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ="
|
||||
},
|
||||
"pause": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
|
||||
"integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10="
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> cad3a32c78620f4c4558fad34991dd48866af8d3
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||
@@ -27,4 +28,39 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
=======
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||
"license": "SAP SAMPLE CODE LICENSE",
|
||||
"dependencies": {
|
||||
"@sap/cds": "latest",
|
||||
"express": "*",
|
||||
"passport": "^0.4.1"
|
||||
},
|
||||
"cds": {
|
||||
"auth": {
|
||||
"passport": {
|
||||
"strategy": "mock",
|
||||
"users": {
|
||||
"alice": {
|
||||
"password": "123",
|
||||
"ID": "alice",
|
||||
"roles": ["admin", "authenticated-user"],
|
||||
"xs.user.attributes": { "currency": [ "USD" ] }
|
||||
},
|
||||
"bob": {
|
||||
"password": "123",
|
||||
"ID": "bob",
|
||||
"roles": ["authenticated-user"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds run --in-memory?",
|
||||
"watch": "cds watch"
|
||||
}
|
||||
>>>>>>> cad3a32c78620f4c4558fad34991dd48866af8d3
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ annotate AdminService.Orders with @odata.draft.enabled;
|
||||
extend service AdminService with {
|
||||
entity OrderItems as select from my.OrderItems;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> cad3a32c78620f4c4558fad34991dd48866af8d3
|
||||
// Restrict access to orders to users with role "admin"
|
||||
annotate AdminService.Orders with @(restrict: [
|
||||
{ grant: 'READ', to: 'admin' }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/** Service implementation for AdminService */
|
||||
module.exports = cds.service.impl(function() {
|
||||
<<<<<<< HEAD
|
||||
this.before ('CREATE', 'Orders', _checkOrderCreateAuth)
|
||||
})
|
||||
|
||||
@@ -8,3 +9,13 @@ module.exports = cds.service.impl(function() {
|
||||
function _checkOrderCreateAuth (req) {
|
||||
req.user.currency[0] === req.data.currency_code || req.reject(403)
|
||||
}
|
||||
=======
|
||||
this.before ('CREATE', 'Orders', _checkOrderCreateAuth)
|
||||
})
|
||||
|
||||
|
||||
/** Check authorization */
|
||||
function _checkOrderCreateAuth (req) {
|
||||
req.user.currency[0] === req.data.currency_code || req.reject(403)
|
||||
}
|
||||
>>>>>>> cad3a32c78620f4c4558fad34991dd48866af8d3
|
||||
|
||||
@@ -24,3 +24,6 @@ async function _reduceStock (req) {
|
||||
)
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user