Commit b1e391a8 authored by Andrew Cohen's avatar Andrew Cohen

auto generated /API

parent cd176fbb
......@@ -78,6 +78,15 @@
"program": "${workspaceRoot}\\leverjs\\JSONtoLEVER.js",
"args":["C:\\z\\leverjs\\Dario\\PC3 siCTRL_Sep07\\01_63x2x_10intsec.json","--force"],
"protocol": "auto"
},
{
"type": "node",
"request": "launch",
"name": "genAPI",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}\\genApiDocs.js",
"args":[],
"protocol": "auto"
}
......
......@@ -457,6 +457,42 @@ function getColorTable(req,res)
});
} // getColorTable
function htmlFromAPI(classID,rgAPI)
{
var html='';
rgAPI=rgAPI.sort();
for (var i=0;i<rgAPI.length;i++) {
var api=rgAPI[i];
api=api.substring("app.get('".length);
api=api.replace(/,\s*function/,'');
api=api.replace(/\'/g,'');
if ('/'===api)
continue;
html+='<div class="'+classID+'">'+api+'</div>'
}
return html;
}
function getAPI()
{
const fs=require('fs');
var code=fs.readFileSync('server.js','utf-8');
var package=fs.readFileSync('package.json','utf-8');
package=JSON.parse(package);
var html='<head><style> .api{color:"black";}</style></head>'
html+='<h1> lever.js version '+package.version+' : auto-generated api </h1>';
html+='<h3> GET methods: </h3>'
var rgAPI=code.match(/app.get\(.*function/g);
html+=htmlFromAPI('api',rgAPI);
rgAPI=code.match(/app.post\(.*function/g);
html+='<h3> POST methods: </h3>'
html+=htmlFromAPI('api',rgAPI);
return html;
}
module.exports.getAPI=getAPI;
module.exports.getColorTable=getColorTable;
module.exports.openDB=openDB;
module.exports.setRenderParams=setRenderParams;
......
......@@ -8,7 +8,7 @@ leverList=webread(url);
fissionEvents={[],[]};
fusionEvents={[],[]};
for f=1:length(leverList)
for f=2:length(leverList)
if ~isempty(strfind(leverList{f},'siCTRL'))
idx=1;
else
......@@ -19,8 +19,11 @@ for f=1:length(leverList)
if isempty(trackList)
continue
end
nFusion= length(find([trackList.t0]>1))/length(trackList);
nFission = length(find([trackList.t1]<max([trackList.t1])))/length(trackList);
% nFusion= length(find([trackList.t0]>1))/length(trackList);
% nFission = length(find([trackList.t1]<max([trackList.t1])))/length(trackList);
nFusion= length(find([trackList.t0]>1));
nFission = length(find([trackList.t1]<max([trackList.t1])));
fissionEvents{idx}=[fissionEvents{idx};nFission];
fusionEvents{idx}=[fusionEvents{idx};nFusion];
nFissionFusion=length(trackList)/length(find([trackList.t0]==1));
......
......@@ -126,6 +126,15 @@ var rawParser = bodyParser.raw({type:'*/*'});
app.use(express.static('./leverjs'));
app.get('/API',function(req,res) {
const helper=require('./leverjs/serverHelper');
var html=helper.getAPI();
res.send(html);
});
app.get('/secure', checkLWT, function(req,res){
console.log('secure')
res.send("no you're secure");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment