Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
awy是一个使用NodeJS开发的Web框架,基于async/await关键字。
如果你使用过1.6.6以前的版本,注意新版本进行了比较大的更新,路由会划分在请求中。
比如,/a支持GET和POST请求,之前的版本是在/a路径中记录GET的回调函数和POST的回调函数。
而新版是先去查找方法(GET、POST···),如果在路由表中存在,则执行请求。
这样的好处是路由根据请求方法分组,相互之间不会有冲突,比如你用/*处理所有请求,之前的方法是会拦截所有的请求,而新的处理方式把它划分到某一请求类型中。 最新版本对获取URL参数、路由参数、POST提交的参数的方式进行了更新。
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
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
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
FAQs
awy is an esay,samll web framework.
We found that awy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.