o-yi
v0.2.2
Published
express generator
Downloads
19
Readme
o-yi
A express generator
Master
Develop
Notice
o-yi 0.2.0+ for node 7.6+.
o-yi 0.1.x for node 4 +
Installation
npm install -g o-yi
GET STARTED
Create project
o-yi new {project name}
Enter {project name} folder
cd {project name}
Generate a CRUD API
o-yi generate {api name}
Add route in api/config/route.js
just like
const user = require('../controller/user.js')
module.exports = [{
user: [
['get', '/', user.find],
['get', '/:id', user.findOne],
['post', '/', user.create],
['put', '/:id', user.update],
['delete', '/:id', user.delete],
]
}]
Before Action
module.exports = [{
user: [
//verify before api
['get', '/', user.findOne, jwt.verify],
//API handler
['get', '/:id', user.findOne],
['post', '/', user.create],
['put', '/:id', user.update],
['delete', '/:id', user.delete],
]
}]