Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dotcom-reliability-kit/serialize-request

Package Overview
Dependencies
Maintainers
4
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotcom-reliability-kit/serialize-request - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

5

lib/index.d.ts
export = serializeRequest;
declare function serializeRequest(request: string | Request, options?: SerializeRequestOptions | undefined): SerializedRequest;
declare namespace serializeRequest {
export { exports as default, ExpressRequest, HttpIncomingMessage, BasicRequest, Request, SerializeRequestOptions, SerializedRequestHeaders, SerializedRequestRouteParams, SerializedRequestRoute, SerializedRequest };
export { DEFAULT_INCLUDED_HEADERS, exports as default, ExpressRequest, HttpIncomingMessage, BasicRequest, Request, SerializeRequestOptions, SerializedRequestHeaders, SerializedRequestRouteParams, SerializedRequestRoute, SerializedRequest };
}

@@ -17,4 +17,5 @@ type Request = (BasicRequest & Record<string, any>) | ExpressRequest | (HttpIncomingMessage & Record<string, any>);

};
declare const DEFAULT_INCLUDED_HEADERS: readonly string[];
declare namespace exports {
export { exports as default, ExpressRequest, HttpIncomingMessage, BasicRequest, Request, SerializeRequestOptions, SerializedRequestHeaders, SerializedRequestRouteParams, SerializedRequestRoute, SerializedRequest };
export { DEFAULT_INCLUDED_HEADERS, exports as default, ExpressRequest, HttpIncomingMessage, BasicRequest, Request, SerializeRequestOptions, SerializedRequestHeaders, SerializedRequestRouteParams, SerializedRequestRoute, SerializedRequest };
}

@@ -21,0 +22,0 @@ type ExpressRequest = import('express').Request;

20

lib/index.js

@@ -62,6 +62,13 @@ /**

*
* @private
* @public
* @type {Array<string>}
*/
const DEFAULT_INCLUDED_HEADERS = ['accept', 'content-type'];
const DEFAULT_INCLUDED_HEADERS = [
'accept',
'accept-encoding',
'accept-language',
'content-type',
'referer',
'user-agent'
];

@@ -188,5 +195,12 @@ /**

module.exports = serializeRequest;
exports = module.exports = serializeRequest;
// We freeze this object so that we avoid any side-effects
// introduced by the way Node.js caches modules. If this
// array is edited within a dependent app, then any changes
// will apply to _all_ uses of `serializeRequest`. This
// could cause some weird issues so we lock it down.
exports.DEFAULT_INCLUDED_HEADERS = Object.freeze([...DEFAULT_INCLUDED_HEADERS]);
// @ts-ignore
module.exports.default = module.exports;
{
"name": "@dotcom-reliability-kit/serialize-request",
"version": "1.0.4",
"version": "1.1.0",
"description": "A utility function to serialize a request object in a way that's friendly to loggers, view engines, and converting to JSON",

@@ -5,0 +5,0 @@ "repository": {

@@ -80,5 +80,18 @@

An array of request headers to include in the serialized request object. This must be an `Array` of `String`s, with each string being a header name. It's important that you do not include headers which include personally-identifiable-information, API keys, or other privileged information. This defaults to `['accept', 'content-type']`.
An array of request headers to include in the serialized request object. This must be an `Array` of `String`s, with each string being a header name. It's important that you do not include headers which include personally-identifiable-information, API keys, or other privileged information.
This option defaults to:
```js
[
'accept',
'accept-encoding',
'accept-language',
'content-type',
'referer',
'user-agent'
]
```
Example of usage:
```js
serializeRequest(request, {

@@ -94,2 +107,14 @@ includeHeaders: [

The default set of headers is also available to use, so that you don't need to repeat them if you want to add new included headers. It can be accessed as `serializeRequest.DEFAULT_INCLUDED_HEADERS`:
```js
serializeRequest(request, {
includeHeaders: [
...serializeRequest.DEFAULT_INCLUDED_HEADERS,
'my-custom-header'
]
});
```
### `SerializedRequest` type

@@ -96,0 +121,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc