Socket
Socket
Sign inDemoInstall

micro-switch-router

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micro-switch-router - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

jest.config.js

13

package.json
{
"name": "micro-switch-router",
"version": "0.0.1",
"version": "0.0.2",
"description": "",

@@ -12,5 +12,12 @@ "main": "src",

"devDependencies": {
"jest": "^23.4.0"
"axios": "^0.18.0",
"jest": "^23.4.0",
"lodash": "^4.17.10",
"test-listen": "^1.1.0"
},
"dependencies": {}
"dependencies": {
"micro": "^9.3.2",
"query-string": "^6.1.0",
"react-router": "^4.3.1"
}
}
const { json } = require('micro')
const qs = require('query-string')
const url = require('url')
const { isDev } = require('../utils/environment')
const enhanceReq = async (req) => {
const parsedUrl = url.parse(req.url)
req.protocol = isDev ? 'http:' : 'https:'
req.originalUrl = `${req.protocol}${req.headers.host}${req.url}`
req.protocol = process.env.NODE_ENV === 'production' ? 'https:' : 'http:'
req.hostname = req.headers.host.split(':')[0] // Remove port # to get hostname
req.port = req.headers.host.split(':')[1] // Remove port # to get hostname
req.pathname = parsedUrl.pathname
/**
* req.headers.host is where the request is pointed
*/
req.search = parsedUrl.search
req.href = parsedUrl.href
req.query = qs.parse(parsedUrl.query)
req.originalUrl = url.format({
protocol: req.protocol,
hostname: req.hostname,
pathname: req.pathname,
query: req.query,
});
req.host = req.headers.host
req.hostname = req.headers.host.split(':')[0] // Remove port # to get hostname
req.body = await json(req).catch(Boolean)
req.query = qs.parse(parsedUrl.query)
}
module.exports = enhanceReq

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