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 🙏

© 2024 – Pkg Stats / Ryan Hefner

awy

v2.0.3

Published

awy is an esay,samll web framework.

Downloads

97

Readme

awy框架

awy是一个使用NodeJS开发的Web框架,基于async/await关键字。

如果你使用过1.6.6以前的版本,注意新版本进行了比较大的更新,路由会划分在请求中。

比如,/a支持GET和POST请求,之前的版本是在/a路径中记录GET的回调函数和POST的回调函数。

而新版是先去查找方法(GET、POST···),如果在路由表中存在,则执行请求。

这样的好处是路由根据请求方法分组,相互之间不会有冲突,比如你用/*处理所有请求,之前的方法是会拦截所有的请求,而新的处理方式把它划分到某一请求类型中。 最新版本对获取URL参数、路由参数、POST提交的参数的方式进行了更新。

支持功能

  • 中间件
  • 路由
  • 路由分组
  • 中间件按照路由规则匹配执行
  • 解析Body数据
  • 解析上传的文件
  • 启用守护进程模式
  • 配置HTTPS

使用示例


const awy = require('awy');

var ar = new awy();

/*
一定要注意的是:
    回调函数要写成async rr的形式。
rr是打包了request和response的对象:
    {
        req,
        res
    }
    
*/

ar.get('/', async rr => {
    rr.res.Body = 'success';        
});

ar.run('localhost', 8080);

curl 'http://localhost:8080/'

输出结果:
  success

获取URL参数(QueryString参数)


const awy = require('awy');

var ar = new awy();

ar.get('/test', async rr => {
    var {name} = rr.req.Param;
    console.log(name);
    rr.res.Body = name;
});

ar.run('localhost', 8080);

curl 'http://localhost:8080/test?name=helo'

输出结果:
  helo

获取POST提交的数据


const awy = require('awy');

var ar = new awy();

ar.post('/pt', async rr => {
    var {username} = rr.req.BodyParam;
    rr.res.Body = username;
});

ar.run('localhost', 8080);

curl 'http://localhost:8080/pt' -d 'username=albert'

返回结果:
  albert

完整文档