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

fast-gateway

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-gateway - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

18

index.js
const fastProxy = require('fast-proxy')
const restana = require('restana')
const pump = require('pump')
const toArray = require('stream-to-array')

@@ -27,2 +29,3 @@ const gateway = (opts) => {

route.hooks.onRequest = route.hooks.onRequest || onRequestNoOp
route.hooks.onResponse = route.hooks.onResponse || onResponse

@@ -56,3 +59,18 @@ // populating pathRegex if missing

const onRequestNoOp = (req, res) => { }
const onResponse = async (req, res, stream) => {
if (!res.hasHeader('content-length')) {
try {
const resBuffer = Buffer.concat(await toArray(stream))
res.statusCode = stream.statusCode
res.setHeader('content-length', '' + Buffer.byteLength(resBuffer))
res.end(resBuffer)
} catch (err) {
res.send(err)
}
} else {
res.statusCode = stream.statusCode
pump(stream, res)
}
}
module.exports = gateway

5

package.json
{
"name": "fast-gateway",
"version": "1.1.2",
"version": "1.2.0",
"description": "A Node.js API Gateway for the masses!",

@@ -31,3 +31,4 @@ "main": "index.js",

"http-cache-middleware": "^1.0.0",
"restana": "^3.1.1"
"restana": "^3.1.1",
"stream-to-array": "^2.3.0"
},

@@ -34,0 +35,0 @@ "devDependencies": {

2

test/smoke.test.js

@@ -233,3 +233,3 @@ /* global describe, it, setImmediate */

await request(gateway)
.post('/users/find')
.post('/users/info')
.expect(404)

@@ -236,0 +236,0 @@ })

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