From 1dd5a23f931e0621cd4324e34c1769a21b1e6227 Mon Sep 17 00:00:00 2001 From: Heiko Witteborg Date: Wed, 18 Jun 2025 09:36:48 +0200 Subject: [PATCH 1/5] Add options param to req.reply --- node.js/events.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/node.js/events.md b/node.js/events.md index c4a05c9e3..6bea3cdfc 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -362,15 +362,19 @@ It's available for CRUD events and bound actions. -### req. reply (results) {.method} +### req. reply () {.method} ```tsx function req.reply ( - results : object | object[] | string | number | true | false | null + results : object | object[] | string | number | true | false | null, + options? : { + mimeType? : string + fileName? : string + } ) ``` -Stores the given argument in `req.results`, which is subsequently sent back to the client, rendered in a protocol-specific way. +Stores the first argument in `req.results`, which is subsequently sent back to the client, rendered in a protocol-specific way. ```js this.on ('READ', Books, req => { @@ -392,6 +396,7 @@ this.on ('READ', Books, req => { }) ``` +The additional `options` parameter can be used to specify content disposition headers in case of [custom streaming (beta)](best-practices#custom-streaming-beta). ### req. reject ({ ... }) {.method #req-reject} From 3e2cb137d40ca6b18a430fb5f6b3ec30f902697b Mon Sep 17 00:00:00 2001 From: Heiko Witteborg Date: Wed, 18 Jun 2025 09:38:27 +0200 Subject: [PATCH 2/5] Update events.md --- node.js/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node.js/events.md b/node.js/events.md index 6bea3cdfc..f2c7dc2de 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -396,7 +396,7 @@ this.on ('READ', Books, req => { }) ``` -The additional `options` parameter can be used to specify content disposition headers in case of [custom streaming (beta)](best-practices#custom-streaming-beta). +The additional `options` argument can be used to specify content disposition headers in case of [custom streaming (beta)](best-practices#custom-streaming-beta). ### req. reject ({ ... }) {.method #req-reject} From 05892e7fdbe089299fbaf151ccc3290c5bcea611 Mon Sep 17 00:00:00 2001 From: Heiko Witteborg Date: Wed, 18 Jun 2025 09:46:34 +0200 Subject: [PATCH 3/5] Update events.md --- node.js/events.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node.js/events.md b/node.js/events.md index f2c7dc2de..138f41cce 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -368,8 +368,8 @@ It's available for CRUD events and bound actions. function req.reply ( results : object | object[] | string | number | true | false | null, options? : { - mimeType? : string - fileName? : string + mimetype? : string + filename? : string } ) ``` From 5ebedcc35bffa7ffff8905cb5e819eac5b588ecc Mon Sep 17 00:00:00 2001 From: Heiko Witteborg Date: Wed, 18 Jun 2025 10:55:54 +0200 Subject: [PATCH 4/5] Fix link in events.md --- node.js/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node.js/events.md b/node.js/events.md index 138f41cce..7cec2293b 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -241,7 +241,7 @@ Additional note about OData: For requests that are part of a changeset, the even -Class `cds.Request` extends [`cds.Event`] with additional features to represent and deal with synchronous requests to services in [event handlers](./core-services#srv-handle-event), such as the [query](#query), additional [request parameters](#params), the [authenticated user](#user), and [methods to send responses](#req-reply-results). +Class `cds.Request` extends [`cds.Event`] with additional features to represent and deal with synchronous requests to services in [event handlers](./core-services#srv-handle-event), such as the [query](#query), additional [request parameters](#params), the [authenticated user](#user), and [methods to send responses](#req-reply). [Router]: https://expressjs.com/en/4x/api.html#router From de5b855015e9ab6093d006fdd9e262729d937348 Mon Sep 17 00:00:00 2001 From: Heiko Witteborg Date: Wed, 18 Jun 2025 10:57:46 +0200 Subject: [PATCH 5/5] Fix link in best-practices.md --- node.js/best-practices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node.js/best-practices.md b/node.js/best-practices.md index 9fda12e5a..aae138d57 100644 --- a/node.js/best-practices.md +++ b/node.js/best-practices.md @@ -387,7 +387,7 @@ Internally the [timestamp](events#timestamp) is a JavaScript `Date` object, that When returning [Media Data](../guides/providing-services#serving-media-data) from a custom `READ`, `action`, or `function` handler, content information can be configured as part of the handlers result object. -Ideally, handlers use [`req.reply`](events#req-reply-results), calling it with an instance of [stream.Readable](https://nodejs.org/api/stream.html#class-streamreadable). Include options to specify content disposition headers: +Ideally, handlers use [`req.reply`](events#req-reply), calling it with an instance of [stream.Readable](https://nodejs.org/api/stream.html#class-streamreadable). Include options to specify content disposition headers: ```js srv.on('READ', 'Books', (req, next) => {