Compare commits
1 Commits
Reuse-Migr
...
esm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cba8e0cc5c |
@@ -1,4 +1,4 @@
|
|||||||
const cds = require('@sap/cds')
|
import cds from '@sap/cds'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In order to keep basic bookshop sample as simple as possible, we don't add
|
* In order to keep basic bookshop sample as simple as possible, we don't add
|
||||||
@@ -8,7 +8,7 @@ const cds = require('@sap/cds')
|
|||||||
|
|
||||||
// NOTE: We use cds.on('served') to delay the UPSERTs after the db init
|
// NOTE: We use cds.on('served') to delay the UPSERTs after the db init
|
||||||
// to run after all INSERTs from .csv files happened.
|
// to run after all INSERTs from .csv files happened.
|
||||||
module.exports = cds.on('served', ()=>
|
export default cds.on('served', ()=>
|
||||||
UPSERT.into ('sap.common.Currencies') .columns (
|
UPSERT.into ('sap.common.Currencies') .columns (
|
||||||
[ 'code', 'symbol', 'name' ]
|
[ 'code', 'symbol', 'name' ]
|
||||||
) .rows (
|
) .rows (
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"name": "@capire/bookshop",
|
"name": "@capire/bookshop",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A simple self-contained bookshop service.",
|
"description": "A simple self-contained bookshop service.",
|
||||||
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"app",
|
"app",
|
||||||
"srv",
|
"srv",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const cds = require('@sap/cds')
|
import cds from '@sap/cds'
|
||||||
|
|
||||||
module.exports = class AdminService extends cds.ApplicationService { init(){
|
export class AdminService extends cds.ApplicationService { init(){
|
||||||
this.before (['NEW','CREATE'],'Authors', genid)
|
this.before (['NEW','CREATE'],'Authors', genid)
|
||||||
this.before (['NEW','CREATE'],'Books', genid)
|
this.before (['NEW','CREATE'],'Books', genid)
|
||||||
return super.init()
|
return super.init()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const cds = require('@sap/cds')
|
import cds from '@sap/cds'
|
||||||
|
|
||||||
class CatalogService extends cds.ApplicationService { init() {
|
export class CatalogService extends cds.ApplicationService { init() {
|
||||||
|
|
||||||
const { Books } = cds.entities('sap.capire.bookshop')
|
const { Books } = cds.entities('sap.capire.bookshop')
|
||||||
const { ListOfBooks } = this.entities
|
const { ListOfBooks } = this.entities
|
||||||
@@ -34,5 +34,3 @@ class CatalogService extends cds.ApplicationService { init() {
|
|||||||
// Delegate requests to the underlying generic service
|
// Delegate requests to the underlying generic service
|
||||||
return super.init()
|
return super.init()
|
||||||
}}
|
}}
|
||||||
|
|
||||||
module.exports = CatalogService
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const cds = require('@sap/cds')
|
import cds from '@sap/cds'
|
||||||
module.exports = class UserService extends cds.Service { init(){
|
export class UserService extends cds.Service { init(){
|
||||||
this.on('READ', 'me', ({ tenant, user, locale }) => ({ id: user.id, locale, tenant }))
|
this.on('READ', 'me', ({ tenant, user, locale }) => ({ id: user.id, locale, tenant }))
|
||||||
this.on('login', (req) => {
|
this.on('login', (req) => {
|
||||||
if (req.user._is_anonymous)
|
if (req.user._is_anonymous)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@capire/bookstore",
|
"name": "@capire/bookstore",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capire/bookshop": "*",
|
"@capire/bookshop": "*",
|
||||||
"@capire/reviews": "*",
|
"@capire/reviews": "*",
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const cds = require ('@sap/cds')
|
import mashup from './srv/mashup.js'
|
||||||
|
import cds from '@sap/cds'
|
||||||
|
|
||||||
// Add mashup logic
|
// Add mashup logic
|
||||||
cds.once('served', require('./srv/mashup'))
|
cds.once('served', mashup)
|
||||||
|
|
||||||
// Add routes to UIs from imported packages
|
// Add routes to UIs from imported packages
|
||||||
cds.once('bootstrap',(app)=>{
|
cds.once('bootstrap',(app)=>{
|
||||||
@@ -10,6 +11,3 @@ cds.once('bootstrap',(app)=>{
|
|||||||
app.serve ('/orders') .from('@capire/orders','app/orders')
|
app.serve ('/orders') .from('@capire/orders','app/orders')
|
||||||
app.serve ('/data') .from('@capire/data-viewer','app/viewer')
|
app.serve ('/data') .from('@capire/data-viewer','app/viewer')
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add Swagger UI
|
|
||||||
require('./srv/swagger-ui')
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
import cds from '@sap/cds'
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Mashing up bookshop services with required services...
|
// Mashing up bookshop services with required services...
|
||||||
//
|
//
|
||||||
module.exports = async()=>{ // called by server.js
|
export default async()=>{ // called by server.js
|
||||||
|
|
||||||
const cds = require('@sap/cds')
|
|
||||||
const CatalogService = await cds.connect.to ('CatalogService')
|
const CatalogService = await cds.connect.to ('CatalogService')
|
||||||
const ReviewsService = await cds.connect.to ('ReviewsService')
|
const ReviewsService = await cds.connect.to ('ReviewsService')
|
||||||
const OrdersService = await cds.connect.to ('OrdersService')
|
const OrdersService = await cds.connect.to ('OrdersService')
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// Adding Swagger UI - see https://cap.cloud.sap/docs/advanced/openapi
|
|
||||||
const cds = require ('@sap/cds')
|
|
||||||
try {
|
|
||||||
const cds_swagger = require ('cds-swagger-ui-express')
|
|
||||||
cds.once ('bootstrap', app => app.use (cds_swagger()) )
|
|
||||||
} catch (err) {
|
|
||||||
if (err.code !== 'MODULE_NOT_FOUND') throw err
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@capire/hello-world",
|
"name": "@capire/hello-world",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npx jest --silent",
|
"test": "npx jest --silent",
|
||||||
"start": "cds-serve srv/world.cds",
|
"start": "cds-serve srv/world.cds",
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
module.exports = class say {
|
import cds from '@sap/cds'
|
||||||
hello(req) {
|
export class say extends cds.ApplicationService {
|
||||||
let {to} = req.data
|
hello (to = 'World') {
|
||||||
if (to === 'me') to = require('os').userInfo().username
|
|
||||||
return `Hello ${to}!`
|
return `Hello ${to}!`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Request } from "@sap/cds"
|
import cds from '@sap/cds'
|
||||||
|
export class say extends cds.ApplicationService {
|
||||||
module.exports = class say {
|
hello (to : String = 'World') {
|
||||||
hello(req: Request) {
|
return `Hello ${to} from TypeScript!`
|
||||||
return `Hello ${req.data.to} from a TypeScript file!`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user