From ec0444e5e8f3db0816a83239e9eede8ef2a4c35c Mon Sep 17 00:00:00 2001 From: sjvans <30337871+sjvans@users.noreply.github.com> Date: Thu, 14 Mar 2024 09:18:33 +0100 Subject: [PATCH 1/4] remove req._ we have req.http now --- node.js/events.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/node.js/events.md b/node.js/events.md index bdb50221f..cc59fe284 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -246,17 +246,6 @@ Class `cds.Request` extends [`cds.Event`] with additional features to represent -### . _ {.property} - -Provides access to original inbound protocol-specific request objects. For events triggered by an HTTP request, it contains the original `req` and `res` objects as obtained from [express.js](https://expressjs.com). {.indent} - -::: warning -Please refrain from using internal properties of that object, that is, the ones starting with '_'. They might be removed in any future release without notice. -::: - - - - ### . method {.property} The HTTP method of the incoming request: From 519060056095908b691ce85098515e55bbe18aac Mon Sep 17 00:00:00 2001 From: sjvans <30337871+sjvans@users.noreply.github.com> Date: Thu, 28 Mar 2024 19:52:46 +0100 Subject: [PATCH 2/4] add header example + warning --- node.js/events.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/node.js/events.md b/node.js/events.md index b76d5fe69..2e0239de6 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -78,15 +78,18 @@ In addition, you can access the current event context from wherever you are in y ### . http {.property} -If the inbound process came from an HTTP channel, this property provides access to express's common [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects. The property is propagated from `cds.context` to all child requests. So, on all handlers, even the ones in your database services, you can always access that property like so: +If the inbound process came from an HTTP channel, this property provides access to express's common [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects. The property is propagated from `cds.context` to all child requests. So, in all handlers, even the ones in your database services, you can always access that property like so: ```js this.on ('*', req => { let { res } = req.http + res.set('Content-Type', 'text/plain') res.send('Hello!') }) ``` +Keep in mind that multiple requests (that is, instances of `cds.Request`) may share the same incoming http request and outgoing http response (for example, in case of an OData batch request). + ### . id {.property} From 480f9311298d5f2904f3dad7dc201d069f1bb3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jeglinsky?= Date: Mon, 24 Jun 2024 08:30:53 +0200 Subject: [PATCH 3/4] Update node.js/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 5ad5949a2..df6804778 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -89,7 +89,7 @@ this.on ('*', req => { }) ``` -Keep in mind that multiple requests (that is, instances of `cds.Request`) may share the same incoming http request and outgoing http response (for example, in case of an OData batch request). +Keep in mind that multiple requests (that is, instances of `cds.Request`) may share the same incoming HTTP request and outgoing HTTP response (for example, in case of an OData batch request). From 4547795f860e4a9d3366b9aec10125843f7e8406 Mon Sep 17 00:00:00 2001 From: Mahati Shankar <93712176+smahati@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:08:43 +0200 Subject: [PATCH 4/4] Update node.js/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 df6804778..3db9f666f 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -79,7 +79,7 @@ In addition, you can access the current event context from wherever you are in y ### . http {.property} -If the inbound process came from an HTTP channel, this property provides access to express's common [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects. The property is propagated from `cds.context` to all child requests. So, in all handlers, even the ones in your database services, you can always access that property like so: +If the inbound process came from an HTTP channel, you can now access express's common [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects through this property. It is propagated from `cds.context` to all child requests, so `Request.http` is accessible in all handlers including your database service ones like so: ```js this.on ('*', req => {