npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngmp

v1.0.6

Published

An promise callback demo

Downloads

13

Readme

测试支持 Node.js 引用 go-mitmproxy

ngmp: Node.js Go MitmProxy

安装使用

npm i ngmp
const { createMitmProxy } = require('ngmp');

createMitmProxy()
  .addAddon({
    hookRequestheaders: async (flow) => {
      console.log('in hookRequestheaders', flow);
    },
    hookRequest: async (flow) => {
      console.log('in hookRequest', flow);
    },
    hookResponseheaders: async (flow) => {
      console.log('in hookResponseheaders', flow);
    },
    hookResponse: async (flow) => {
      console.log('in hookResponse', flow);
      flow.response.setBody('hello world');
    },
  })
  .start()
  .registerCloseSignal();

可多次调用 addAddon 实现不同功能的逻辑模块,每个 Addon 里面实现 hookRequestheaders, hookRequest, hookResponseheaders, hookResponse 这四个方法其中一个或多个即可。

目前所有配置均写死,后续可考虑在 createMitmProxy时传入配置参数,用于配置监听的端口号、是否启用 web ui 等功能。

开发

思路:c++ 里面循环调用 golang 方法,golang 方法阻塞,直到有数据,然后再 BlockingCall 至 js callback 中

编译 golang 代码为静态库

go build -o libngmp.a -buildmode=c-archive cmd/main.go

本地编译与测试

npm i
node example.js

发布

npm publish

目前仅会将本地编译的 libngmp.a 发布至 npm 上面去,所以目前只能 Apple M1 环境下可以测试使用。

参考