This commit is contained in:
Daniel
2020-03-08 12:42:33 +01:00
parent 84a815e7e6
commit 48fa640f5b
12 changed files with 65 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
namespace sap.capire.bookshop; namespace sap.capire.bookshop;
// using { Currency, managed, sap } from '@sap/cds/common'; using { Currency, managed, sap } from '@sap/cds/common';
using { Currency, managed, sap } from '@capire/common'; // using { Currency, managed, sap } from '@capire/commorn';
entity Books : managed { entity Books : managed {
key ID : Integer; key ID : Integer;

3
bookshop/index.cds Normal file
View File

@@ -0,0 +1,3 @@
using from './db/schema';
using from './srv/cat-service';
using from './srv/admin-service';

1
bookshop/index.js Normal file
View File

@@ -0,0 +1 @@
exports.CatalogService = require('./srv/cat-service')

31
bookshop/readme.md Normal file
View File

@@ -0,0 +1,31 @@
# Bookshop Getting Started Sample
This sample introduces the essential tasks in the development of CAP-based services as also covered in the [Getting Started guide in capire](https://cap.cloud.sap/docs/get-started/in-a-nutshell).
## Hypothetical Use Cases
1. Build a service that allows to browse _Books_ and _Authors_.
2. Books have assigned _Genres_ which are organized hierarchically.
3. All users may browse books without login.
4. All entries are maintained by Administrators.
5. End users may order books (the actual order mgmt being out of scope)
## Running the Sample
```sh
npm run watch
```
## Content & Best Practices
| Links to capire | Sample files / folders |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| [Project Setup and Layouts](https://cap.cloud.sap/docs/get-started/projects#sharing-and-reusing-content) | [`./`](./) |
| [Defining Domain Models](https://cap.cloud.sap/docs/guides/domain-models) | [`./db/schema.cds`](./db/schema.cds) |
| [Defining Services](https://cap.cloud.sap/docs/guides/providing-services) | [`./srv/*.cds`](./srv) |
| [Single-purposed Services](https://cap.cloud.sap/docs/guides/providing-services#single-purposed-services) | [`./srv/*.cds`](./srv) |
| [Generic Providers](https://cap.cloud.sap/docs/guides/generic-providers) | http://localhost:4004 |
| [Using Databases](https://cap.cloud.sap/docs/guides/databases) | [`./db/data/*.csv`](./db/data) |
| [Adding Custom Logic](https://cap.cloud.sap/docs/guides/service-impl) | [`./srv/*.js`](./srv) |
| [Adding Tests](https://cap.cloud.sap/docs/guides/testing) | [`./test`](./test) |
| [Sharing for Reuse](https://cap.cloud.sap/docs/get-started/projects#sharing-and-reusing-content) | [`./index.cds`](./index.cds) |

View File

@@ -1,5 +1,5 @@
const cds = require ('@sap/cds') const cds = require ('@sap/cds')
const { expect } = require('chai') .use (require('chai-subset')) const {expect} = cds.require.chai
describe('reading/writing hierarchies', ()=>{ describe('reading/writing hierarchies', ()=>{

View File

@@ -1,4 +1,4 @@
using AdminService from '@capire/bookshop/srv/admin-service'; using AdminService from '@capire/bookshop';
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// //

View File

@@ -1,4 +1,4 @@
using CatalogService from '@capire/bookshop/srv/cat-service'; using CatalogService from '@capire/bookshop';
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// //

View File

@@ -2,7 +2,7 @@
Common Annotations shared by all apps Common Annotations shared by all apps
*/ */
using { sap.capire.bookshop as my } from '@capire/bookshop/db/schema'; using { sap.capire.bookshop as my } from '@capire/bookshop';
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////

View File

@@ -1,3 +1,3 @@
// Proxy for importing schema from bookshop sample // Proxy for importing schema from bookshop sample
using from '@capire/bookshop/db/schema'; using from '@capire/bookshop';
namespace sap.capire.bookshop; namespace sap.capire.bookshop;

View File

@@ -1,3 +1,3 @@
// Proxy for importing services from bookshop sample // Proxy for importing services from bookshop sample
using from '@capire/bookshop/srv/admin-service'; using from '@capire/bookshop';
annotate AdminService with @impl:'srv/admin-service.js'; annotate AdminService with @impl:'srv/admin-service.js';

View File

@@ -1,4 +1,4 @@
using { sap.capire.bookshop.Books } from '@capire/bookshop/db/schema'; using { sap.capire.bookshop.Books } from '@capire/bookshop';
using { Currency, managed, cuid } from '@sap/cds/common'; using { Currency, managed, cuid } from '@sap/cds/common';
namespace sap.capire.bookshop; namespace sap.capire.bookshop;

21
reviews/readme.md Normal file
View File

@@ -0,0 +1,21 @@
# Reviews Service Sample
## Run all-in-one
Open a terminal window and run the bookshop in it:
```sh
npm run bookshop
```
## Run as separate services
Open two terminal windows, and in the first one start the reviews service stand-alone:
```sh
npm run reviews-service
```
In the the second one start the bookshop:
```sh
npm run bookshop
```