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

node-vc

v0.4.0

Published

A light weight node view-controller framework

Readme

node-vc

一个不到200行代码的"node 视图-控制器"小框架。

特性

路由映射

'post:/submit' : 'handlerName'handlerName会处理/submit请求的post类型。

json及html

可以在运行时随时随地改变json输出还是基于ejs的html输出

例子

如何开始

配置文件 nodevc.json

配置一个nodevc.json文件,如果你在控制台中运行node app.js,你必须把 nodevc.json 文件跟app.js文件放在同一个文件夹下。

在我下面定义的例子中,views文件夹和controllers文件夹都是在项目根目录。

{
	"port" : "8080",
	"views_folder" : "views",
	"controllers_folder" : "controllers",
	"mapping" : {
		"/" : "common.index",
		"/index_json" : "common.index_json"
	}
}
  • port: web服务器的port
  • views_folder: ejs模板所在的文件夹
  • controllers_folder: 控制器所在的文件夹
  • mapping: 路由配置,例如当请求首页的时候,会映射到 common.js 的 index 函数。

创建一个视图

在上面定义的views文件夹下创建一个index.ejs文件。

创建控制器

在上面定义的controllers文件夹下建立一个common.js文件,然后在里面写两个函数。

// http:locahost:8080/ 的get类型的请求会定位到这里
// 这个函数会用返回的数据{data:"Hello node-vc"}渲染index.ejs文件
exports.index = function(req, resp, callback){
  callback(0, 'index', {data : 'Hello node-vc!'});
}

// http:locahost:8080/index_json 的get类型的请求会定位到这里
// 这个函数没有指定视图
// 在callback的第二个参数传递0
// 会把{data : 'Hello World'}直接返回json字符串到浏览器端。
exports.index_json = function(req, resp, params, callback){
  callback(0, 0, {data : 'Hello node-vc!'});
}

// 在params中获取你传的参数
exports.controller = (req, resp, params, callback){
  
}