
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
一个本地模拟接口
npm install test-ajax
var test_ajax = require('test-ajax');
test_ajax({
base: './',//项目根目录
prot: 90, //端口
cache_path: "./__cache/", //缓存文件的路径,基于base
global: {
test: '我是测试的'
},
static_path: ['/static/'], //静态域,基于url
admin: '/admin/', //后台域,基于url
doc: '/doc/', //文档域,基于url
open: true,//是否打开浏览器
md: true,//md文档
beforeSend: function(req, res){//请求前回调,返回false则不请求接口,这里不算静态资源,后台,文档
}
});
number, 端口,默认90
string, 缓存目录,基于base(文件路径)
object, 通用参数,在返回值里使用,如:
({
global:{
'500': 500,
'404': '{"errcode": "404"}'
}
})
返回值里使用(注:需要开启编译):
<%=global['500']%>
<%=global['404']%>
array, 静态资源目录,比如模板,样式,以url开始
string, 后台路径,url开始
string, 文档路径,url开始
boolean, 是否打开浏览器
jsonpnode-combo时的处理(ps:下一个要研究的东西就是node-combo&&单元测试)这套机制适合我吧,因为我们项目静态域单独,但接口是以根目录开始的,比如我使用的目录大概是:
本地静态:static.xx.me/
tpl/ html模板
js/ js文件,这里写接口都是以 url: '/api/login' 方式,因为到后端(线上)时就是这个目录
css/ 样式
api/ 本地接口测试
以上是本地环境,接口使用test-ajax调试
线上静态:static.xx.me/
js/ js文件,这里写接口都是以 url: '/api/login' 方式,因为到后端(线上)时就是这个目录
css/ 样式
线上正式: www.xx.com/
api/ 接口目录
以上是正式环境,接口走正式的server端,无需切换
当然test-ajax只是一种思路,适合自己项目的才是最好的~
FAQs
The npm package test-ajax receives a total of 3 weekly downloads. As such, test-ajax popularity was classified as not popular.
We found that test-ajax 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.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.