node-basis
v1.0.8
Published
This package is help programmer to develop nodeJs program.
Downloads
2
Maintainers
Readme
##node-basis usege
node i node-basis
You need create app.js
the code example:
/backend interface restful/ basis.setRouter({ "controllerName1":"/api/:id/:version", "controllerName2":"/", "interface":"/restful/info" });
basis.controller("controllerName1",function(req,res,argv){ res.writeHead(200,{'content-type':'text/html'}); res.write("This is request."); res.write("params id:"+argv.id); res.write("params version:"+argv.version); res.end(); });
basis.controller("interface",function(req,res){ /向客户端输出JSON/ res.writeHead(200,{'content-type':'text/javascript'}); res.write('{"data":[1,2,3,4],"errorCode":"0"}'); /restfull interface data/ res.end(); });
basis.start(3000);