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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-less-server

v1.0.7

Published

A simple server for developing static pages. You can enable proxy requests, or you can customize requests to return data

Readme

simple-less-server

用于开发静态页面的简单服务器。您可以启用代理请求,也可以自定义路由返回数据

A simple server for developing static pages. You can enable proxy requests, or you can customize the route to return data

  • 使用场景是,在开发几个轻量级页面的时候,简单配置就可以启用一个服务器
  • 这是一个与http请求方法无关的服务器,如果需要验证,你可以在路由函数中使用request.method进行自定义处理
  • 调用start后,路由的path如果是字符串会被处理成正则对象
  • 监听到请求后,会按序遍历路由,请求的url通过验证后就会停止遍历并执行路由函数

处理优先级

静态目录 > 代理拦截 > routeUse添加的路由 > 最后404

Install

npm i simple-less-server

use:

const path = require('path')

app = server({
  log: true, //是否在控制台打印请求地址
  http: { //http服务器配置
    open: true,
    port: 3000,
    option: {}
  },
  https: { //https服务器配置
    open: true,
    port: 3443,
    key: path.join(__dirname, './key.pem'), //证书私钥key
    cert: path.join(__dirname, './cert.pem'), //签名证书cert
    option: {}
  },
  staticPath: __dirname, //静态资源目录
  proxyOpen: true, //代理是否开启
  proxyConfig: { //需要代理的目标对象,请求地址有/api都会代理,权重
    '/api': {
      target: 'http://127.0.0.1:3001', //代理的目标地址
      referer: true, //是否代理修改请求的来源为代理地址,会修改请求头的referer,Host为本地服务器地址
      pathRewrite: { //重写
        '^/api': ''
      }
    }
  },
  lessRoutesCache: [{ //第一种路由初始化方法
      path: '/hello', //路由地址
      func: (request, response) => {
        response.body = 'hello world!'
      }
    },
    { //第一种路由初始化方法
      path: '/text', //路由地址
      func: (request, response) => {
        response.body = '一段中文文字'
      }
    }
  ]
})

app.routeUse('/test', (request, response) => {
  response.body = "The request name is '/api/test'"
})
app.routeUse('/getList', (request, response) => {
  response.status(200)
  response.json({
    list: [1, null, true, 'abc', '文字']
  })
})

app.routeUse('/error', (request, response) => {
  response.status(500)
  response.body = 'server error...'
})

app.start()

request

属性

  • url url
  • hostname 域名
  • port 端口
  • path 请求路径
  • query url上的参数
  • params body上的参数

response

response.status() 设置返回的状态码 response.json() 设置返回的json字符串