express-mysql-restful-generator(名字有点长,求测字起名)
给每个表生成对应的restful接口文件,作为Router使用在你的express项目中。|generate files for restful api for each table, require them as routers and use in your app
- 可用于现有的express项目|designed for an working express
- 所有的逻辑都是生成的,都可以改|more flexable
用到的项目|related projects
- bookshelf.js http://www.bookshelfjs.org/
- ng-admin https://ng-admin-book.marmelab.com/
如果不是现有的项目,就新建一个|prepare a working express if you don't have one
mkdir myprojcd myprojnpm initnpm install express --savevi app.js #copy code into app.js node app.js
app.js
var express = ;var app = ; // respond with "hello world" when a GET request is made to the homepageapp; app
使用本项目生成restful代码|use this to generate code
npm install express-mysql-restful-generator --savenode node_modules/express-mysql-restful-generator/cli.js#path_for_generated_files #host #user #password #db #done! vi app.js
应用这些生成的代码|use generated code
app.js
var express = ;var app = ;app// respond with "hello world" when a GET request is made to the homepageapp; app
定制情况(自由发挥)|cases
//defaultapp //only tableapp)
定制Router的实现(具体修改自由发挥)|customize table router/actions
vi path_for_generated_files/table_name #and modify it
默认的restful规则|restful standard
- listView => GET /users
- creationView => POST /users
- showView => GET /users/:id
- editionView => PUT /users/:id
- deletionView => DELETE /users/:id
/restful/test_table/1
"id":1"name":"2017-01-13 12:56:25"
后台管理页面|admin page
/restful/admin/
- using ng-admin https://github.com/marmelab/ng-admin