Code Style Guide
Developers are advised to use npm init egg --type=simple showcase
to generate and observe the recommended project structure and configuration.
# Classify
Old Style:
module.exports = app => { |
change to:
const Service = require('egg').Service; |
Additionally, the framework developer
needs to change the syntax as follows, otherwise the application developer
will have problems customizing base classes such as Service:
const egg = require('egg'); |
# Private Properties & Lazy Initialization
- Private properties are mounted with
Symbol
. - The description of Symbol follows the rules of jsdoc, describing the mapped class name + attribute name.
- Delayed initialization.
// app/extend/application.js |