Create Module

2018-12-08 12:28:18

Create Module

Entry into project cabloy-demo, execute shell command egg-born, create a module named as test-todo

$ cd cabloy-demo
$ egg-born src/module/test-todo --type=module-business

Two module templates are currently available:

name description
mudule-business this template creates business-related code that greatly simplifies the workload
module this template contains only the basic skeleton code files

Naming Convention

In order to increase the business modules continuously and achieve a highly reusable effect, the namespace of all modules must be fully isolated, to avoid mutual pollution and conflict. Thus the naming convention is as follows:

name description
providerId the unique code of provider: Github’s Username is strongly recommended to ensure that modules contributed to the community do not conflict
moduleName the name of module

Based on this naming convention, module-related resources are referenced at the frontend and backend as follows:

Module egg-born-module-test-todo as example

name description
providerId test
moduleName todo
fullName egg-born-module-test-todo
relativeName test-todo
frontend page route url /test/todo/{page}
backend api route url /test/todo/{controller}/{action}

Restart Services

$ npm run dev:backend
$ npm run dev:front


Now the project has realized the features of create, delete, update, select and search of todo. It also has realized the features of star and label. At the same time, it has realized two menu items of create todo and todo list, and had assigned the corresponding menu and data rights to the user root.


Next, we gradually introduce some basic features and usage of the framework on the basis of the module `test-todo’

Then we will go back and introduce how the features of create, delete, update, select and search of todo are realized, and how to add new features on this basis