
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
JavaScript请求服务负载均衡,仿nginx upstream
fetch
返回ok=true
表示可用upstreamCache
var hosts = ["lib.baomitu.com", "unpkg.com"];
//所有源请求完或默认超时
upstream(hosts, function (fast, ok) {
//fast:最快的源
//ok:可用的源 数组
console.log(fast, ok)
});
//最快的一个源或默认超时
upstream(hosts, function (fast, ok) {
console.log(fast, ok)
}, 1);
//所有源请求完或自定义超时
upstream(hosts, function (fast, ok) {
console.log(fast, ok)
}, 280);
//主机头跳转或404等,须请求具体路径的情况
upstream([
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js",
"https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js",
"https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"
], function (fast, ok) {
console.log(fast, ok);
//根据ok变量提取可用的源
});
/*
实战:使用跨域代理解决不能直接请求API的情况,且转换HTTP为HTTPS协议
https://ss.netnr.com/weather
一个天气接口,直接发起请求存在跨域的问题,而且是HTTP协议
配置多个跨域服务的源,调用跨域服务得到API数据
*/
upstream(["https://proxy.zme.ink/", "https://bird.ioliu.cn/v2?url="], function (fast) {
var api = "http://wthrcdn.etouch.cn/weather_mini?citykey=101040100";
var url = fast + api;
fetch(url).then(res => res.json()).then(data => console.log(data));
}, 1);
FAQs
JavaScript请求服务负载均衡,仿nginx upstream
The npm package upstreamjs receives a total of 0 weekly downloads. As such, upstreamjs popularity was classified as not popular.
We found that upstreamjs 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.