diff --git a/db/init.js b/db/init.js index 77a50c0..9a59dd4 100644 --- a/db/init.js +++ b/db/init.js @@ -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 @@ -8,7 +8,7 @@ const cds = require('@sap/cds') // NOTE: We use cds.on('served') to delay the UPSERTs after the db init // to run after all INSERTs from .csv files happened. -module.exports = cds.on('served', ()=> +cds.on('served', ()=> UPSERT.into ('sap.common.Currencies') .columns ( [ 'code', 'symbol', 'name' ] ) .rows ( diff --git a/package.json b/package.json index 209ec8a..dcdd14c 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "2.1.11", "description": "Our primer sample for getting started in a nutshell.", "repository": "https://github.com/capire/bookshop", + "type": "module", "files": [ "app", "srv", diff --git a/srv/admin-service.js b/srv/admin-service.js index f3e910f..4508c75 100644 --- a/srv/admin-service.js +++ b/srv/admin-service.js @@ -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'],'Books', genid) return super.init() diff --git a/srv/cat-service.js b/srv/cat-service.js index 985001f..67adb7b 100644 --- a/srv/cat-service.js +++ b/srv/cat-service.js @@ -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 { ListOfBooks } = this.entities @@ -25,5 +25,3 @@ class CatalogService extends cds.ApplicationService { init() { // Delegate requests to the underlying generic service return super.init() }} - -module.exports = CatalogService