current position:Home>Egg enterprise framework - Installation
Egg enterprise framework - Installation
2021-08-27 08:59:17 【iwhao_ top】
This is my participation 8 The fourth of the yuegengwen challenge 23 God , Check out the activity details :8 Yuegengwen challenge
Design principles
We are well aware that enterprise application is pursuing standardization and co construction at the same time , You also need to think about how to balance the differences between different teams , Seek common ground while reserving differences . So we didn't choose the big bazaar model of the common framework of the community ( Integration is like a database 、 template engine 、 Front end framework and other functions ), It's about focusing on providing Web Development of core functions and a set of flexible and extensible plug-in mechanism . We don't make technology choices , Because fixed technology selection will make the scalability of the framework worse , Can't meet all kinds of customization needs . adopt Egg, The team's architects and technical leaders can easily build on their own technical architecture Egg On this basis, we expand the framework suitable for our own business scenarios .
Egg The plug-in mechanism of is highly extensible , A plug-in only does one thing ( such as Nunjucks The template encapsulates into egg-view-nunjucks、MySQL The database is encapsulated as egg-mysql).Egg Aggregate these plug-ins through the framework , And customize the configuration according to your own business scenarios , In this way, the development cost of the application becomes very low .
Egg Pursue 『 Convention over configuration 』, According to a set of unified agreement for application development , Adopting this approach within the team can reduce the learning costs of developers , Developers are no longer 『 A nail 』, It can flow . There is no agreed team , The cost of communication is very high , For example, some people will divide the stack by directory, while others will divide the function by directory , It's easy for developers to make mistakes if they don't have the same perception . But convention doesn't mean poor scalability , contrary Egg It's highly scalable , The framework can be customized according to the agreement of the team . Use Loader You can let the framework define the default configuration according to different environments , It can also cover Egg The default agreement of .
And express difference
Express yes Node.js A framework widely used by the community , Simple and extensible , Great for personal projects . But the framework itself lacks conventions , The standard MVC Models can be written in various ways .Egg Develop as agreed , Pursue 『 Convention over configuration 』, The cost of teamwork is low .
Sails Is and Egg The same is true 『 Convention over configuration 』 Framework , It's also very scalable . But compared to the Egg,Sails Support Blueprint REST API、WaterLine So scalable ORM、 Front end Integration 、WebSocket etc. , But these functions are all created by Sails Provided . and Egg No direct functionality , It's just the integration of various functional plug-ins , Such as the implementation egg-blueprint,egg-waterline And so on , Reuse sails-egg Framework integration of these plug-ins can replace Sails 了 .
Quick start
This article will be from the perspective of examples , Step by step, build a Egg.js application , Let you get started quickly Egg.js.
Environmental preparation
operating system : Support macOS,Linux,Windows Running environment : Suggested choice LTS edition , Minimum requirements 8.x. Quick initialization We recommend using scaffolding directly , Just a few simple instructions , You can quickly build projects (npm >=6.1.0):
$ mkdir egg-example && cd egg-example
$ npm init egg --type=simple
$ npm i
Copy code
Quick initialization
We recommend using scaffolding directly , Just a few simple instructions , You can quickly build projects (npm >=6.1.0):
$ mkdir egg-example && cd egg-example
$ npm init egg --type=simple
$ npm i
Copy code
Start project :
$ npm run dev
$ open http://localhost:7001
Copy code
characteristic
- Offer based on Egg The ability to customize the upper framework
- Highly extensible plug-in mechanism
- Built in multi process management
- be based on Koa Development , Excellent performance
- The frame is stable , High test coverage
- Progressive development
Directory structure
In the QuickStart , You should have a preliminary impression of the framework , Next, let's take a brief look at the directory convention specification .
egg-project
├── package.json
├── app.js ( Optional )
├── agent.js ( Optional )
├── app
| ├── router.js
│ ├── controller
│ | └── home.js
│ ├── service ( Optional )
│ | └── user.js
│ ├── middleware ( Optional )
│ | └── response_time.js
│ ├── schedule ( Optional )
│ | └── my_task.js
│ ├── public ( Optional )
│ | └── reset.css
│ ├── view ( Optional )
│ | └── home.tpl
│ └── extend ( Optional )
│ ├── helper.js ( Optional )
│ ├── request.js ( Optional )
│ ├── response.js ( Optional )
│ ├── context.js ( Optional )
│ ├── application.js ( Optional )
│ └── agent.js ( Optional )
├── config
| ├── plugin.js
| ├── config.default.js
│ ├── config.prod.js
| ├── config.test.js ( Optional )
| ├── config.local.js ( Optional )
| └── config.unittest.js ( Optional )
└── test
├── middleware
| └── response_time.test.js
└── controller
└── home.test.js
Copy code
The directory agreed by the framework :
- app/router.js Used for configuration URL Routing rules , Specific see Router.
- app/controller/** Used to parse user input , Return corresponding results after processing , Specific see Controller.
- app/service/** For writing the business logic layer , Optional , It is recommended to use , Specific see Service.
- app/middleware/** For writing middleware , Optional , Specific see Middleware.
- app/public/** Used to place static resources , Optional , See the built-in plug-ins for details egg-static.
- app/extend/** Extension for framework , Optional , See framework extension for details .
- config/config.{env}.js For writing configuration files , See configuration for details .
- config/plugin.js For configuring plug-ins that need to be loaded , See plug-ins for details .
- test/** For unit testing , See unit test for details .
- app.js and agent.js Used to customize initialization at startup , Optional , Please refer to start customization for details . About agent.js For more information, see Agent Mechanism .
Directory contracted by built-in plug-ins :
- app/public/** Used to place static resources , Optional , See the built-in plug-ins for details egg-static.
- app/schedule/** For timed tasks , Optional , See timing task for details .
To customize your own directory specification , See Loader API
- app/view/** Used to place template files , Optional , Agreed by the template plug-in , See template rendering for details .
- app/model/** For placing domain models , Optional , Agreed by domain class related plug-ins , Such as egg-sequelize.
That's all the content of this article , Thank you very much for seeing here , If this article is well written or a little helpful to you , Please thumb up , Please pay attention to , Please share , Of course, any questions can be discussed in the comments , I will answer positively , Thank you again for
copyright notice
author[iwhao_ top],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2021/08/20210827085915256l.html
The sidebar is recommended
- Crazy blessing! Tencent boss's "million JVM learning notes", real topic of Huawei Java interview 2020-2021
- JS JavaScript how to get the subscript of a value in the array
- How to implement injection in vuex source code?
- JQuery operation select (value, setting, selected)
- One line of code teaches you how to advertise on Tanabata Valentine's Day - Animation 3D photo album (music + text) HTML + CSS + JavaScript
- An article disassembles the pyramid architecture behind the gamefi outbreak
- BEM - a front-end CSS naming methodology
- [vue3] encapsulate custom global plug-ins
- Error using swiper plug-in in Vue
- Another ruthless character fell by 40000, which was "more beautiful" than Passat and maiteng, and didn't lose BMW
guess what you like
-
Huang Lei basks in Zhang Yixing's album, and the relationship between teachers and apprentices is no less than that in the past. Netizens envy Huang Lei
-
He was cheated by Wang Xiaofei and Li Chengxuan successively. Is an Yixuan a blessed daughter and not a blessed home?
-
Zhou Shen sang the theme song of the film "summer friends and sunny days" in mainland China. Netizen: endless aftertaste
-
Pink is Wangyuan online! Back to the peak! The new hairstyle is creamy and sassy
-
Front end interview daily 3 + 1 - day 858
-
Spring Webflux tutorial: how to build reactive web applications
-
[golang] walk into go language lesson 24 TCP high-level operation
-
August 23, 2021 Daily: less than three years after its establishment, Google dissolved the health department
-
The female doctor of Southeast University is no less beautiful than the female star. She has been married four times, and her personal experience has been controversial
-
There are many potential safety hazards in Chinese restaurant. The top of the program recording shed collapses, and the artist will fall down if he is careless
Random recommended
- Anti Mafia storm: He Yun's helpless son, Sun Xing, is destined to be caught by his dry son
- Introduction to flex flexible layout in CSS -- learning notes
- CSS learning notes - Flex layout (Ruan Yifeng tutorial summary)
- Today, let's talk about the arrow function of ES6
- Some thoughts on small program development
- Talk about mobile terminal adaptation
- Unwilling to cooperate with Wang Yibo again, Zhao Liying's fans went on a collective strike and made a public apology in less than a day
- JS function scope, closure, let, const
- Zheng Shuang's 30th birthday is deserted. Chen Jia has been sending blessings for ten years. Is it really just forgetting to make friends?
- Unveil the mystery of ascension
- Asynchronous solution async await
- Analysis and expansion of Vue infinite scroll source code
- Compression webpack plugin first screen loading optimization
- Specific usage of vue3 video play plug-in
- "The story of huiyeji" -- people are always greedy, and fairies should be spotless!
- Installing Vue devtool for chrome and Firefox
- Basic usage of JS object
- 1. JavaScript variable promotion mechanism
- Two easy-to-use animation JS that make the page move
- Front end Engineering - scaffold
- Java SQL Server intelligent fixed asset management, back end + front end + mobile end
- Mediator pattern of JavaScript Design Pattern
- Array de duplication problem solution - Nan recognition problem
- New choice for app development: building mobile applications using Vue native
- New gs8 Chengdu auto show announces interior Toyota technology blessing
- Vieira officially terminated his contract and left the team. The national security club sent blessings to him
- Less than 200000 to buy a Ford RV? 2.0T gasoline / diesel power, horizontal bed / longitudinal bed layout can be selected
- How does "heart 4" come to an end? Pinhole was boycotted by the brand, Ma Dong deleted the bad comments, and no one blessed him
- We are fearless in epidemic prevention and control -- pay tribute to the front-line workers of epidemic prevention!
- Front end, netty framework tutorial
- Xiaomi 11 | miui12.5 | android11 solves the problem that the httpcanary certificate cannot be installed
- The wireless charging of SAIC Roewe rx5 plus is so easy to use!
- Upload and preview pictures with JavaScript, and summarize the most complete mybatis core configuration file
- [25] typescript
- CSS transform Complete Guide (Second Edition) flight.archives 007
- Ajax foundation - HTTP foundation of interview essential knowledge
- Cloud lesson | explain in detail how Huawei cloud exclusive load balancing charges
- Decorator pattern of JavaScript Design Pattern
- [JS] 10. Closure application (loop processing)
- Left hand IRR, right hand NPV, master the password of getting rich