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

node_power_server

v1.1.12

Published

This is a node api and proxy server, based on koa

Readme

node-power-server

Description


Node-Power-Server 是为了让node中间件(前端后置层)的实现更简单,基于Koa, Request

方便实现简单的代理转发,以及集成接口调用

Quickstart


Installation

npm install node_power_server --save

Usage

    const path = require("path")
    const NodePowerServer = require("node_power_server")
    
    const server = new NodePowerServer.Server({
        port: 8009, //指定端口(必须)
        staticRoot: `${path.join(__dirname, "static")}`, //指定静态文件路径(可选,如果需要做静态资源服务的话)
    	handlerDir: `${path.join(__dirname, "handler")}` //指定前置api路径(可选,如果需要前置api,集成调用后端api的话)
    });
    
    //添加代理表, 指定需要被转发的路径,以及被转发到的目标[协议+域名+【端口】+【地址】], prefix[前缀] 将会被去掉
    server.config.proxyTable.add("/api9081", "http://127.0.0.1:9081/mc")
                            .add("/api9082", "http://127.0.0.1:9082")
    
    //添加中间件, 该例子中对所有请求添加跨域处理,并且指定处理的时间点在调用接口前
    //如果需要其他中间件,可自行开发,参考中间件源码实现
    //注意: 中间件对静态资源无效, 后置中间件对代理转发无效, 前、后置中间件对 front api 都有效
    server.middlewares.add("/*", NodePowerServer.Middleware.CrossDomain(),NodePowerServer.Middleware.Constant.ExecBefore)
    
    //监听服务启动事件
    server.on("started", () => {
        console.log("server started successfully")
    })
    server.on("init_process", message => {
        console.log(message)
    })
    
    //正式启动,绑定端口
    server.start()

前置api建议写法


    //在指定的handler中创建需要的api文件夹,文件名以.分割 如:user.info.get 是一个api, 里面有个index.js
    //结构赋值, 具体有什么属性,可以参考koa 的request对象
    //函数返回值,就是接口返回内容
    module.exports = async ({body, query}) => {
        return {
            id: ctx.request.query.id,
            nickname: 'leo',
            age: 24,
            address: '天朝'
        }
    }

更多用法,参考测试用例