Zum Hauptinhalt springen

Bauen und testen

Um eine möglichst hohe Developer Experience zu ermöglichen, musst du nicht die App erst hochladen, damit du diese testen kannst.

Das devkit bietet einen eingebauten Proxy, welcher HTTP Requests entgegennehmen kann und an deine App weiterleitet. Das Gegenstück deiner Schnittstelle wird hierbei simuliert, wodurch du dich beim Entwickeln sehr nah am Live System bewegst.

Die App selber kannst du nun mit folgendem Befehl bauen:

$ soda-devkit build

> asset logo.png 13.6 KiB [compared for emit] [from: assets/logo.png] [copied]
> asset entrypoint.js 6.68 KiB [compared for emit] [minimized] (name: main)
> orphan modules 1.96 KiB [orphan] 1 module
> modules by path ./node_modules/@soda-sync/app-sdk/dist/src/ 10.6 KiB
> modules by path ./node_modules/@soda-sync/app-sdk/dist/src/contracts/ 1.43 KiB 19 modules
> modules by path ./node_modules/@soda-sync/app-sdk/dist/src/sdk/ 1.29 KiB
> modules by path ./node_modules/@soda-sync/app-sdk/dist/src/sdk/*.js 1.07 KiB 7 modules
> modules by path ./node_modules/@soda-sync/app-sdk/dist/src/sdk/configuration/*.js 154 bytes 2 modules
> + 1 module
> modules by path ./node_modules/@soda-sync/app-sdk/dist/src/bindings/ 1.81 KiB
> modules by path ./node_modules/@soda-sync/app-sdk/dist/src/bindings/http/*.js 308 bytes 4 modules
> modules by path ./node_modules/@soda-sync/app-sdk/dist/src/bindings/*.js 231 bytes 3 modules
> ./node_modules/@soda-sync/app-sdk/dist/src/bindings/errors/terminate-re...(truncated) 1.28 KiB [built] [code generated]
> ./node_modules/@soda-sync/app-sdk/dist/src/index.js 3.28 KiB [built] [code generated]
> ./node_modules/@soda-sync/app-sdk/dist/src/utilities/page-number-converter.js 2.83 KiB [built] [code generated]
> ./src/index.ts + 1 modules 2.43 KiB [built] [code generated]
> ./node_modules/@soda-sync/app-sdk/dist/package.json 459 bytes [built] [code generated]
> webpack 5.85.0 compiled successfully in 962 ms

Anschließend kannst du mit folgendem Befehl den Proxy starten:

$ soda-devkit proxy

> Listening on http://localhost:1337
Port

Sollte der Standardport belegt sein, kannst du mit -p PORT einen beliebigen anderen Port angeben.

Du kannst unter http://localhost:1337/use-feature/:feature den Endpunkt für das zu testende Feature aufrufen.

In diesem Fall wäre der Aufruf (Im Folgenden zur einfachheit nur noch "Testseite") http://localhost:1337/use-feature/orders-provide

Beispielausgabe:

{
"pageSize": 100,
"nextPageToken": "123",
"data": [
{
"id": "fwg4adftwsgb",
"orderNumber": "ORD#123",
"orderDate": "2023-06-02 21:45:00",
"status": "OPEN",
"items": [
{
"id": "s3ilguasd",
"sku": "A12",
"name": "Eine Bestellposition",
"description": "Beschreibung der Position",
"amount": 1,
"singleNetPrice": {
"value": 1000,
"divisor": 100
},
"singleGrossPrice": {
"value": 1190,
"divisor": 100
},
"taxRate": 19
}
],
"shipments": [],
"transactions": []
}
]
}