New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

daruk-request-id

Package Overview
Dependencies
Maintainers
7
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daruk-request-id - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

.idea/daruk-request-id.iml

5

package.json
{
"name": "daruk-request-id",
"version": "0.4.0",
"version": "0.4.1",
"description": "koa request id",
"main": "./lib/index.js",
"typings": "./index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "node ./node_modules/.bin/tsc"
"build": "tsc"
},

@@ -10,0 +11,0 @@ "repository": {

0

README.md

@@ -0,0 +0,0 @@ # daruk-request-id

@@ -6,7 +6,7 @@ /**

/*!
* x-request-id
* Copyright(c) 2015 Fangdun Cai
* MIT Licensed
*/
/*!
* x-request-id
* Copyright(c) 2015 Fangdun Cai
* MIT Licensed
*/

@@ -17,3 +17,3 @@ /**

import uuid from "uuid/v4";
import uuid from 'uuid/v4';

@@ -30,4 +30,4 @@ const HTTP_X_REQUEST_ID_HEADER = 'X-Request-Id';

* @param {string} [key=HTTP_X_REQUEST_ID_HEADER]
* @param {bool} [noHyphen=false]
* @param {bool} [inject=false]
* @param {boolean} [noHyphen=false]
* @param {boolean} [inject=false]
* @api public

@@ -43,8 +43,8 @@ */

export function xRequestId (options: Options, app: any) {
options = options || {}
const key = options.key || HTTP_X_REQUEST_ID_HEADER
const noHyphen = !!options.noHyphen
const inject = !!options.inject
options = options || {};
const key = options.key || HTTP_X_REQUEST_ID_HEADER;
const noHyphen = !!options.noHyphen;
const inject = !!options.inject;
if (inject) {
if (!app) throw new TypeError('`app` must be required!')
if (!app) throw new TypeError('`app` must be required!');
Object.defineProperty(app.request, 'id', {

@@ -57,3 +57,3 @@ get: function () {

}
})
});
Object.defineProperty(app.context, 'id', {

@@ -67,8 +67,8 @@ get: function () {

return (ctx: any, next: Function) => {
var id = ctx.id || ctx.query[key] || ctx.get(key) || uuid()
if (noHyphen) id = id.replace(/-/g, '')
if (inject) ctx.request.id = id
ctx.set(key, id)
var id = ctx.id || ctx.query[key] || ctx.get(key) || uuid();
if (noHyphen) id = id.replace(/-/g, '');
if (inject) ctx.request.id = id;
ctx.set(key, id);
return next()
}
}

@@ -0,0 +0,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