
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.