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 🙏

© 2025 – Pkg Stats / Ryan Hefner

interfacemapping

v1.0.5

Published

类似于内网穿透

Downloads

9

Readme

InterfaceMapping快速上手

安装

npm install -S express
npm install -S socket.io
#安装依赖
npm install -S interfacemapping-centre
#安装中心服务
npm install -S interfacemapping-margin
#安装边缘服务

使用

中心服务器(centre)

一般中心服务器是一个公网的服务器,接下来的代码是放置在公网服务的node应用上的代码。

const express = require('express');
const http = require('http');
const im = require('interfacemapping-centre');

let app = express();
let server = http.Server(app);
server.listen(3000);//监听3000端口

im.service(app,server);
//启动服务器
    
im.mapping(im.createRoute({name:'a',token:'1234'}));
//创建路由并映射margin服务器上的api
//name为路由名称
//token为路由的密码
//每个路由目前只能连接一个margin服务器,当前用户连接后,其他用户会连接失败

边缘服务器(margin)

边缘服务器可以是公网的也可以是内网的,下面是代码说明。

const im = require('interfacemapping-margin');

im.origin({
    //远程连接
    host:'http://localhost',
    //主机地址
    port:'3000',
    //服务端口
    name:'a',
    //路由名称
    token:'1234'
    //连接密码
});

//这里就于express语法很相似
im.get('/test1',(req,res)=>{
    //req.query 获取ajax传值
    //req.headers 获取报文头
    
    res.send({success:1,mag:req.query});
    //响应数据
},{maxRequest:10});
//限制这个接口同时访问人数10,默认不限制

im.get('/test2',(req,res)=>{
    res.send({success:1,mag:req.query}); 
});

im.post('/test3',(req,res)=>{
    //req.body post的传值
    res.send({success:1,mag:req.query}); 
});

im.mapping();//映射同步接口

浏览器代码

$.ajax({
      type: "get",
      url: "/a/test2",
      //注意这里必须要加上路由
      data:{a:3},
      success: function (response) {
      	 console.log(response);//{success:1,mag:{a:3}}
	  }
});

如果想和我一起修改这个项目,你可以去给我提交申请

有问题你也可以给我留言