
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
used in expressjs, app.use('/xxx', httpFunc({args:['string', 'string', 'callback']}, function(s1, s2, callback) {callback(null, s1+s2);}))
用于express,将http请求翻译成函数调用.
httpf可以接受url以及body中的参数。使用body时需要在前面加上
app.use(bodyParser.urlencoded());
app.all('/f1', httpf({p1:'string', p2:'number', p3:'date'}, function(p1, p2, p3, cb) {
assert(typeof p1==='string'
&& typeof p2 === 'number'
&& p3 instanceof Date);
return 'ok';
}));
app.all('/f2', httpf(['string', 'number', 'date', 'callback'], function(p1, p2, p3, cb) {
assert(typeof p1==='string'
&& typeof p2 === 'number'
&& p3 instanceof Date);
cb(null,'ok');
}));
如果在opt中包含callback,f的最后一个参数将会是回调函数,给客户端的返回值需要从这里传出。 e.g
app.all('/f',httpf({callback:1}, function(callback) {
callback(null, 'ok');
}));
否则直接通过return给出返回值
如果含有no_return标记,httpf不向res中写入任何数据,此时f需要自行管理向客户端返回数据。这通常用于下载文件。 e.g
app.use('/dl', httpf({name:'string', no_return:true}, function(name) {
require('fs').createReadStream(name).pipe(this.res);
}));
app.all('/f',httpf(function() {
return httpf.text('hello!');
}));
这个函数用来构造text/html类型的返回值
除非定义了no_return, 总是一个json字符串
{"result":"ok"|"error", message:"something", ...}
result='ok' 代表函数成功,返回值一般在message中,或者就是这个对象本身
result='error', 执行失败,错误在message中。
上述返回值在下一版会被修改成
{err:"something wrong"} || {message:"ok", ...}
0.0.6 增加了跨域支持,CDN不再会缓冲httpf返回的数据
从0.0.7开始。支持jsonp调用。但是不能自定义$.ajax({jsonp})这个关键字,必须是默认的'callback'。
FAQs
used in expressjs, app.use('/xxx', httpFunc({args:['string', 'string', 'callback']}, function(s1, s2, callback) {callback(null, s1+s2);}))
We found that httpf 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.