最近闲着,突发奇想,顺便也实践了一下,于是诞生了。我可以用打字稿装饰器写一个NodejsSpringMVC,然后我有这个项目。项目支持:DependencyinjectionController,ServiceinjectionGET/POST/PUT/DELETE/PATCH等rest方法解析restapi的参数,比如RequestParam上传文件支持Mu??lter支持在vscode中直接调试typescript代码想学习如何调试typescript代码同学们可以关注一下,真的很有用。直接上readMe的部分内容:安装npmieasy-node-ioc--saveQuickStart查看test中的快速启动示例。用法1.CreateaControllerimport{Controller}from'easy-node-ioc';@Controller('/test')classTestControl{...}2.CreateaServiceimport{Service}from'easy-node-ioc';@Service('')classTestService{...}3.InjectServiceimport{Autowired,Controller}from'easy-node-ioc';@Controller('/test')classTestControl{@AutowiredtestService:TestService;...}4.DefineRestAPI:GET,POST,PUT,DELETE,PATCHImport{Autowired,Controller,GET,RequestParam}from'easy-node-ioc';@Controller('/test')classTestControl{@Autowired测试服务:测试服务;@Get('/index')index(@RequestParam('age')age:number,req:Request,res:Response){console.log('indexmethod');this.dbService.queryDb();res.status(200).send(this.testService.queryDb());}...}4.DefineStartAppimport{Bootstrap,ComponentScan}来回m"../";@ComponentScan(join(__dirname,"./Controller.ts"))@BootstrapclassApp{constructor(){}app=express();main(){constserver=http.createServer(this.app);server.listen(9001,function(){console.log("示例应用在http://%s:%s监听");});}}如何调试如果你使用vscode,跟着就好。vscode/launch.json,选择LaunchProgram。如果您看到示例应用程序已启动。在控制台中,则表示测试用例启动成功。尝试调用http://localhost:9001/api/test/index.gitHub地址:https://github.com/chenkang08...说明:由于这个项目也是心血来潮,可能会有问题。不过我在公司用这个包改写了一个node后台项目,一切正常。.同时,欢迎issues,如果觉得还可以,也可以给我一个star。
