Node.js – 如何编写用于Express的脚手架生成器
我想写我自己的脚手架发电机的Express框架。 我意识到有这样的框架,但我想写我自己的。 我希望function类似于Rails。
例如:
generate model user name:String email:String
应在模型目录中创builduser.js
,并在模式中使用两个指定的字段。
我也想为模型生成控制器,使用db连接器进行crud操作:
generate controller users mongoose
应该在controllers目录中创buildusers.j
,并且应该包含基于users.j
api的crud操作。
我该如何去做同样的事情?
PS:后端是IOS应用程序的REST API,所以我不感兴趣生成视图。
如果你想在节点js MVC框架与发电机function,那么我更喜欢
CompoundJS
路线和语法也更类似于轨道上的ruby
您还可以通过compound generate crud post title content
来执行CRUD
对于控制器compound g controller controllername actionName anotherActionName
对于模型compound g model user name password createdAt:date activated:boolean
对于脚手架compound g scaffold post title content createdAt:date
谢谢