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

easyserver.js

v0.1.5

Published

![EasyServer.js logo](http://gao111.top/img/logo.jpg) ## 继承自express的简单服务器,不需要为路由而烦恼 ### [测试项目](https://github.com/332065255/easy_test)

Downloads

3

Readme

简单的服务器

EasyServer.js logo

继承自express的简单服务器,不需要为路由而烦恼

测试项目

目录约束

config目录(必须)

  • 该目录是config模块自动加载,根据NODE_ENV进行主动加载对应的.js or .json文件
  • 不管NODE_ENV是什么,默认加载default.js or default.json
  • default.js 默认应有内容
    • "rootPath": '' 这是给框架提供项目根目录 (默认已有,如不必须,不用写该参数)

    • "port":9889 项目启动端口号

routes(路由目录,必须,重要!!!!!请仔细阅读)

  • routes根目录下应都为文件夹

  • routes根目录下不能有.js文件

  • http://domain/ 请求的路由地址为 /routes/index/index.js 下的indexAction

  • http://domain/user/index/ 请求的路由地址为 /routes/user/index.js 下的indexAction

  • http://domain/user 请求的路由地址为 /routes/user/index.js 下的indexAction

  • http://domain/user/index 请求的路由地址为 /routes/user/index.js 下的indexAction

  • http://domain/user/getname 请求的路由地址为 /routes/user/index.js 下的getnameAction

  • http://domain/user/reg/ 请求的路由地址为 /routes/user/reg.js 下的indexAction

  • http://domain/user/reg/logup 请求的路由地址为 /routes/user/reg.js 下的logupAction

  • routes目录下所有.js文件必须都继承自Router

views(渲染文件目录,必须)

  • views目录下有且仅有html文件
  • routes目录下.js文件display方法,默认无参数时,访问的是/views/1级路由.html
    • 举例 http://domain/user/index 如果indexAction中执行了display()方法,那么渲染的就是/views/user.html
    • 举例 http://domain/user/index 如果indexAction中执行了display("index.html")方法,那么渲染的就是/views/index.html
    • 举例 http://domain/user/index 如果indexAction中执行了display("/lib/index.html")方法,那么渲染的就是/views/lib/index.html

static(静态资源目录)

  • 该目录下可以存放任何东西,可以通过http://domain/static/xxx.xxx 直接访问
  • views目录下的html文件,里面如果使用静态文件,比如图片,比如js等,看下面示例
    • 图片:
    • JS文件:
    • 注意,静态文件的起始目录永远为'/static'

API

EasyServer

  • start()方法 启动服务器,默认端口是9889

Router(此类应为被继承类,建议不要直接使用)

  • before()方法,请求进入该对象后,第一个执行的方法,返回FALSE,即立即结束后续操作
  • xxxAction()子类自定义方法,使用方式如下
    • http://domain/user/index/getUser 请求的路由地址为 /routes/user/index.js 下的getUserAction()方法
    • 该方法返回false,即立即结束后续操作
    • 该方法应都为post请求
    • xxx应全部为小写,因为浏览器地址栏不支持大写
  • __call() 方法,如果请求路由没有击中任何xxxAction()方法,那么默认执行该方法,返回false,即立即结束后续操作
  • after()方法,最后执行方法

安装方式

npm install easyserver.js -S

import {EasyServer,Router} from 'EasyServer'
let server = new EasyServer();
server.start();

Licence

MIT