Compare commits
15 Commits
openSAP-we
...
openSAP-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b97da977e5 | ||
|
|
50085fe7be | ||
|
|
8c3733c9cd | ||
|
|
a412c41970 | ||
|
|
e49e9ae823 | ||
|
|
6cc2741c3e | ||
|
|
06755978b2 | ||
|
|
02469acebb | ||
|
|
e2b47228db | ||
|
|
13480ad99e | ||
|
|
8071faa62d | ||
|
|
9ea294586a | ||
|
|
a56a11ff3e | ||
|
|
b4084b45cb | ||
|
|
26e3c0d753 |
41
.vscode/launch.json
vendored
41
.vscode/launch.json
vendored
@@ -5,45 +5,18 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "bookshop",
|
||||
"request": "launch",
|
||||
"type": "node",
|
||||
"runtimeExecutable": "npx",
|
||||
"runtimeArgs": [
|
||||
"-n"
|
||||
],
|
||||
"args": [
|
||||
"--",
|
||||
"cds",
|
||||
"run",
|
||||
"--in-memory"
|
||||
],
|
||||
"name": "bookshop", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
|
||||
"args": [ "--", "cds", "run", "--in-memory" ],
|
||||
"cwd": "${workspaceFolder}/packages/bookshop",
|
||||
"console": "integratedTerminal",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
]
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
},
|
||||
{
|
||||
"name": "cds run ...",
|
||||
"request": "launch",
|
||||
"type": "node",
|
||||
"runtimeExecutable": "npx",
|
||||
"runtimeArgs": [
|
||||
"-n"
|
||||
],
|
||||
"args": [
|
||||
"--",
|
||||
"cds",
|
||||
"run",
|
||||
"--with-mocks",
|
||||
"--in-memory?"
|
||||
],
|
||||
"name": "cds run ...", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
|
||||
"args": [ "--", "cds", "run", "--with-mocks", "--in-memory?" ],
|
||||
"cwd": "${workspaceFolder}/packages/${input:service}",
|
||||
"console": "integratedTerminal",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
]
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
@@ -61,4 +34,4 @@
|
||||
"default": "bookshop"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ In SAP Business Application Studio, open a terminal.
|
||||
Then clone the repo with this specific branch:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week3-unit4
|
||||
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week3-unit1
|
||||
cd projects/cloud-cap-samples
|
||||
```
|
||||
|
||||
|
||||
@@ -8,7 +8,11 @@
|
||||
"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": "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": "^3",
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
{
|
||||
"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": "^3",
|
||||
"express": "^4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds run --in-memory?",
|
||||
"watch": "cds watch"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": {
|
||||
"model": [
|
||||
"db",
|
||||
"srv"
|
||||
],
|
||||
"kind": "sqlite"
|
||||
}
|
||||
}
|
||||
"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": "^3",
|
||||
"express": "^4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds run --in-memory?",
|
||||
"watch": "cds watch"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": {
|
||||
"kind": "sql"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using { sap.capire.bookshop as my } from '../db/schema';
|
||||
|
||||
service AdminService @(_requires:'authenticated-user') {
|
||||
service AdminService @(_requires:'authenticated-user',path:'/admin') {
|
||||
entity Books as projection on my.Books;
|
||||
entity Authors as projection on my.Authors;
|
||||
entity Orders as select from my.Orders;
|
||||
@@ -10,7 +10,7 @@ service AdminService @(_requires:'authenticated-user') {
|
||||
annotate AdminService.Orders with @odata.draft.enabled;
|
||||
// annotate AdminService.Books with @odata.draft.enabled;
|
||||
|
||||
// Temporary workaround -> https://github.wdf.sap.corp/cap/issues/issues/3121
|
||||
// Temporary workaround -> cap/issues#3121
|
||||
extend service AdminService with {
|
||||
entity OrderItems as select from my.OrderItems;
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@ service CatalogService {
|
||||
@requires_: 'authenticated-user'
|
||||
@insertonly entity Orders as projection on my.Orders;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,4 @@ async function _reduceStock (req) {
|
||||
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
|
||||
)
|
||||
}))
|
||||
}
|
||||
}
|
||||
25
packages/bookshop/tests/authors.http
Normal file
25
packages/bookshop/tests/authors.http
Normal file
@@ -0,0 +1,25 @@
|
||||
### Service Document
|
||||
GET http://localhost:4004/admin/Authors
|
||||
|
||||
### Create Author
|
||||
POST http://localhost:4004/admin/Authors HTTP/1.1
|
||||
content-Type: application/json
|
||||
|
||||
{
|
||||
"ID": 105,
|
||||
"name": "J.K. Rowling",
|
||||
"dateOfBirth": null,
|
||||
"dateOfDeath": null,
|
||||
"placeOfBirth": "",
|
||||
"placeOfDeath": ""
|
||||
}
|
||||
### Update Author
|
||||
PATCH http://localhost:4004/admin/Authors/105 HTTP/1.1
|
||||
content-Type: application/json
|
||||
|
||||
{
|
||||
"placeOfBirth": "United Kingdom"
|
||||
}
|
||||
|
||||
### Delete Author
|
||||
DELETE http://localhost:4004/admin/Authors/105 HTTP/1.1
|
||||
Reference in New Issue
Block a user