This server acts as reference implementation and baseline for the client side test tool.
The tool provides a simple test server to evaluate the varying settings. To prepare the server, execute the following:
- Clone the repository to your machine
- Execute the dependency installation in the main directory
npm i
- Either run the server via
cds watch
or build and deploy it to the SAP BTP.
To optimize the performance of propagating mass changes (in my case merely creates) from client to server, the server implements a special service. This service is called MassChangeService
and is located in the srv
folder. The service is a simple wrapper around the standard ReferenceService
and provides a generic action insertAll
to insert multiple entities at once. The service is defined as follows:
@protocol: 'rest'
service MassChangeService {
@open
type AnyArray {};
action insertAll(insEntity : String, insArray: AnyArray) returns AnyArray;
}
The implementation of the service is then handled in ./srv/handlers/mass.js.
The standard CAP REST adapter uses the limitation from the underlying 'express' framework. That means, that the maximum size of a request is 100kb. If you want to increase this limit, you currently must patch the @sap/cds-rest/libx/rest/RestAdapter.js
file and change the following
- router.use(express.json()) // REVISIT: -> belongs to the parses
+
+
+ console.log('MST - REST Adapter Patch: Set limit to 50mb')
+ router.use(express.json({limit:'50mb'})) // REVISIT: -> belongs to the parses
+ //router.use(express.json()) // REVISIT: -> belongs to the parses
You can use the npm package patch-package
to patch the file automatically.
When you run patch-package with the latest version of npm, you will get an error message. To fix this, you can use the following set of commands:
- delete
package-lock.json
npm i --lockfile-version 2
npx patch-package --patch-dir ./patches @sap/cds
- delete
package-lock.json
one more time npm i