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

an-node-proxy

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

an-node-proxy

`an-node-proxy` is an http proxying library, supports both http and https, and also supports proxy to local data with the need of mock request

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

an-node-proxy

an-node-proxy is an http proxying library, supports both http and https, and also supports proxy to local data with the need of mock request

Features

  • http proxy
  • https proxy
  • mock
  • more headers, au and so on
  • improve readme
  • an tool to produce index

Installation

npm install an-node-proxy --save

Ussage

http proxy

import {createServer} from 'http'
import {createProxyServer} from 'an-node=proxy'

// proxy server
createProxyServer({
  target: 'http://localhost:8001'
}).listen(8000)

// target server
createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' })
  res.write(`request from ${req.socket.localAddress}, and headers are ${JSON.stringify(req.headers, null, 2)}`)
  res.end()
}).listen(8001)

so does https, an-node-proxy also support

middileware

import express from 'express'
import {createServer} from 'http'
import {createProxy} from 'an-node-proxy'

const app = new express()
const proxy = createProxy({
    target: 'http://localhost:8004'
})

app.use((req, res) => {
    proxy.proxy(req, res)
})

app.listen(8003)

// target server
createServer((req, res) => {
    res.writeHead(200, { 'Content-Type': 'text/plain' })
    res.write(`request from ${req.socket.localAddress}, and headers are ${JSON.stringify(req.headers, null, 2)}`)
    res.end()
}).listen(8004)

mock

import {createServer} from 'http'
import {createProxyServer} from 'an-node-proxy'

// mock server
createProxyServer({
  mock: {
      rules: [
          {
              from: '/test',
              to: './examples/mock'
          },
          {
              from: '/test/a.js',
              to: './examples/a.js'
          }
      ]
  }
}).listen(8005)

FAQs

Package last updated on 28 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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