topbit 3.0.4 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,128 +1,21 @@
1
- 木兰宽松许可证, 第2版
1
+ Copyright (c) [2025] [Copyright Holder]
2
2
 
3
- 木兰宽松许可证, 第2版
4
- 2020年1月 http://license.coscl.org.cn/MulanPSL2
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
5
6
 
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6
14
 
7
- 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
15
+ ---------------------------------------------
8
16
 
9
- 0. 定义
17
+ 版权所有 (c) [2025] [版权所有者]
10
18
 
11
- “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
12
-
13
- “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
14
-
15
- “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
16
-
17
- “法人实体”是指提交贡献的机构及其“关联实体”。
18
-
19
- “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
20
-
21
- 1. 授予版权许可
22
-
23
- 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
24
-
25
- 2. 授予专利许可
26
-
27
- 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
28
-
29
- 3. 无商标许可
30
-
31
- “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
32
-
33
- 4. 分发限制
34
-
35
- 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
36
-
37
- 5. 免责声明与责任限制
38
-
39
- “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
40
-
41
- 6. 语言
42
- “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
43
-
44
- 条款结束
45
-
46
- 如何将木兰宽松许可证,第2版,应用到您的软件
47
-
48
- 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
49
-
50
- 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
51
-
52
- 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
53
-
54
- 3, 请将如下声明文本放入每个源文件的头部注释中。
55
-
56
- Copyright (c) [Year] [name of copyright holder]
57
- [Software Name] is licensed under Mulan PSL v2.
58
- You can use this software according to the terms and conditions of the Mulan PSL v2.
59
- You may obtain a copy of Mulan PSL v2 at:
60
- http://license.coscl.org.cn/MulanPSL2
61
- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
62
- See the Mulan PSL v2 for more details.
63
-
64
-
65
- Mulan Permissive Software License,Version 2
66
-
67
- Mulan Permissive Software License,Version 2 (Mulan PSL v2)
68
- January 2020 http://license.coscl.org.cn/MulanPSL2
69
-
70
- Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
71
-
72
- 0. Definition
73
-
74
- Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
75
-
76
- Contribution means the copyrightable work licensed by a particular Contributor under this License.
77
-
78
- Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
79
-
80
- Legal Entity means the entity making a Contribution and all its Affiliates.
81
-
82
- Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
83
-
84
- 1. Grant of Copyright License
85
-
86
- Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
87
-
88
- 2. Grant of Patent License
89
-
90
- Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
91
-
92
- 3. No Trademark License
93
-
94
- No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4.
95
-
96
- 4. Distribution Restriction
97
-
98
- You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
99
-
100
- 5. Disclaimer of Warranty and Limitation of Liability
101
-
102
- THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
103
-
104
- 6. Language
105
-
106
- THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
107
-
108
- END OF THE TERMS AND CONDITIONS
109
-
110
- How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
111
-
112
- To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
113
-
114
- i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
115
-
116
- ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
117
-
118
- iii Attach the statement to the appropriate annotated syntax at the beginning of each source file.
119
-
120
-
121
- Copyright (c) [Year] [name of copyright holder]
122
- [Software Name] is licensed under Mulan PSL v2.
123
- You can use this software according to the terms and conditions of the Mulan PSL v2.
124
- You may obtain a copy of Mulan PSL v2 at:
125
- http://license.coscl.org.cn/MulanPSL2
126
- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
127
- See the Mulan PSL v2 for more details.
19
+ 特此授权,允许出于任何目的使用、复制、修改和/或分发本软件,无论是否收费,前提是必须在所有副本中保留上述版权声明和本许可声明。
128
20
 
21
+ 本软件按“原样”提供,作者不作任何明示或暗示的保证,包括但不限于适销性和特定用途适用性的暗示保证。在任何情况下,作者均不对因使用或运行本软件而引起的或与之相关的任何特殊、直接、间接或后果性损害,或因使用、数据或利润损失而导致的任何损害承担责任,无论是在合同诉讼、疏忽或其他侵权行为诉讼中。
package/README.cn.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Topbit
4
4
 
5
- [English Documentation](README.en.md)
5
+ #### [English Documentation](README.en.md)
6
6
 
7
7
  topbit是基于Node.js的运行于服务端的Web框架,它没有任何第三方依赖,在独特的路由和中间件分组执行机制上进行了极致优化。
8
8
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Topbit
4
4
 
5
- [中文文档](README.cn.md)
5
+ #### [🪭 中文文档 ☯️](README.cn.md)
6
6
 
7
7
  Topbit is a server-side Web framework based on Node.js. It has no third-party dependencies and is optimized for extreme performance with a unique routing and middleware grouping execution mechanism.
8
8
 
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ module.exports = [
4
+ {
5
+ middleware: async (ctx, next) => {
6
+ console.log(`global ${ctx.path} start`)
7
+ await next(ctx)
8
+ console.log(`global ${ctx.path} end`)
9
+ }
10
+ }
11
+ ]
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+
3
+ class Test {
4
+ constructor() {
5
+
6
+ }
7
+
8
+ async get(ctx) {
9
+ ctx.ok([
10
+ ctx.method, ctx.path, ctx.routepath, ctx.param
11
+ ])
12
+ }
13
+
14
+ __mid() {
15
+ return [
16
+ {
17
+ middleware: async (ctx, next) => {
18
+ console.log(`test ${ctx.method} start`)
19
+ await next(ctx)
20
+ console.log(`test ${ctx.method} end`)
21
+ }
22
+ }
23
+ ]
24
+ }
25
+ }
26
+
27
+ module.exports = Test
@@ -10,6 +10,18 @@ class Api {
10
10
  ctx.method, ctx.path, ctx.routepath, ctx.param
11
11
  ])
12
12
  }
13
+
14
+ __mid() {
15
+ return [
16
+ {
17
+ middleware: async (ctx, next) => {
18
+ console.log(`api ${ctx.method} start`)
19
+ await next(ctx)
20
+ console.log(`api ${ctx.method} end`)
21
+ }
22
+ }
23
+ ]
24
+ }
13
25
  }
14
26
 
15
27
  module.exports = Api
package/demo/loader.js CHANGED
@@ -7,7 +7,7 @@ let {Loader} = Topbit
7
7
 
8
8
  let app = new Topbit({
9
9
  debug: true,
10
- //loadInfoFile: '--mem',
10
+ loadInfoFile: '--mem',
11
11
  })
12
12
 
13
13
  if (app.isWorker) {
@@ -22,6 +22,8 @@ if (app.isWorker) {
22
22
 
23
23
  app.sched('none')
24
24
 
25
- app.autoWorker(3)
25
+ app.autoWorker(12)
26
26
 
27
- app.daemon(1234, 1)
27
+ app.daemon(1234, 5)
28
+
29
+ //console.log(app.midware.midGroup)
package/docs/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Extensions Document
2
+
3
+ ## 中文版
4
+
5
+ [TopbitLoader](./topbit-loader.md)
6
+
7
+ [TopbitToken](./topbit-token.md)
8
+
9
+
10
+ ---
11
+
12
+ ## English Document
13
+
14
+ [TopbitLoader](./topbit-loader.md)
15
+
16
+ [TopbitToken](./topbit-token.md)
@@ -0,0 +1,305 @@
1
+ # TopbitLoader Complete User Manual
2
+
3
+ ---
4
+
5
+ ### 1. What is TopbitLoader?
6
+
7
+ TopbitLoader is the official recommended auto-loading extension for the Topbit framework. It completely eliminates the need to manually write `app.get()`, `app.post()`, `app.use()`, etc.
8
+
9
+ It implements a true MCM pattern (Middleware → Controller → Model) — lightweight, ultra-fast, and perfectly aligned with Topbit’s extreme-performance philosophy.
10
+
11
+ **One sentence summary:**
12
+ > Write your project following the conventional directory structure, then just call `new Loader().init(app)` once — all routes, middlewares, and models are automatically loaded.
13
+
14
+ ---
15
+
16
+ ### 2. Recommended Project Structure
17
+
18
+ ```
19
+ project/
20
+ ├── app.js # Entry file (full example below)
21
+ ├── controller/ # Controllers (required)
22
+ │ ├── __mid.js # Global middleware list (optional)
23
+ │ ├── user.js # → /user group
24
+ │ ├── admin/ # Sub-group
25
+ │ │ ├── __mid.js # Middleware only for admin group
26
+ │ │ └── index.js # → /admin
27
+ │ └── api/
28
+ │ ├── __mid.js
29
+ │ └── v1/
30
+ │ └── post.js # → /api/v1/post
31
+ ├── middleware/ # Class-style middlewares (required)
32
+ │ ├── @auth.js # Must start with @
33
+ │ ├── @cors.js
34
+ │ └── rate-limit.js # Plain function middleware (less common)
35
+ └── model/ # Models (optional)
36
+ └── user.js
37
+ ```
38
+
39
+ ---
40
+
41
+ ### 3. 30-Second Quick Start
42
+
43
+ ```js
44
+ // app.js
45
+ 'use strict'
46
+ process.chdir(__dirname)
47
+
48
+ const Topbit = require('topbit')
49
+ const { Loader } = Topbit
50
+
51
+ const app = new Topbit({
52
+ debug: true,
53
+ http2: true,
54
+ allowHTTP1: true,
55
+ cert: './cert/fullchain.pem',
56
+ key: './cert/privkey.pem'
57
+ })
58
+
59
+ if (app.isWorker) {
60
+ // One line only – everything is auto-loaded
61
+ new Loader().init(app)
62
+ }
63
+
64
+ app.autoWorker(16) // Max elastic workers
65
+ app.daemon(443, 4) // 4 base workers
66
+ ```
67
+
68
+ Run `node app.js` → full-featured service is up!
69
+
70
+ ---
71
+
72
+ ### 4. Configuration Options
73
+
74
+ | Option | Type | Default | Description |
75
+ |----------------------|--------------------|---------------|-------------------------------------------------------------------------------------------------|
76
+ | `appPath` | string | `.` | Project root directory |
77
+ | `controllerPath` | string | `./controller`| Controller folder |
78
+ | `midwarePath` | string | `./middleware`| Middleware class folder |
79
+ | `prePath` | string | `''` | Global route prefix (e.g. `/api/v1`) |
80
+ | `subgroup` | string\|Array | `null` | Load only specified subdirectories (e.g. `['admin','api']`) |
81
+ | `fileAsGroup` | boolean | `true` | Highly recommended – each controller file becomes its own route group (precise middleware) |
82
+ | `optionsRoute` | boolean | `true` | Auto-add `OPTIONS /*` routes for CORS preflight |
83
+ | `multi` | boolean | `false` | Allow multiple `init()` calls (keep `false` in production) |
84
+ | `homeFile` | string | `''` | Which file serves the root `/` route (e.g. `'index.js'`) |
85
+ | `initArgs` | any | `app.service` | Arguments passed to every controller’s `init()` method |
86
+ | `beforeController` | function | `null` | Hook executed after controller instantiation, before route registration |
87
+ | `afterController` | function | `null` | Hook executed after route registration |
88
+ | `modelLoader` | async function | `null` | Powerful extension point – custom model loading (recommended with topbit-model) |
89
+
90
+ **Most common production config:**
91
+
92
+ ```js
93
+ new Loader({
94
+ prePath: '/api/v1',
95
+ fileAsGroup: true,
96
+ optionsRoute: true,
97
+ modelLoader: async (service) => {
98
+ const UserModel = require('./model/user')
99
+ service.userModel = new UserModel(service)
100
+ }
101
+ }).init(app)
102
+ ```
103
+
104
+ ---
105
+
106
+ ### 5. Controller Writing Guide
107
+
108
+ #### 5.1 Minimal RESTful Style (Recommended)
109
+
110
+ ```js
111
+ // controller/user.js
112
+ class User {
113
+ async get(c) { // GET /user/:id
114
+ c.to({ id: c.param.id })
115
+ }
116
+ async list(c) { // GET /user
117
+ c.to(['alice', 'bob'])
118
+ }
119
+ async post(c) { // POST /user
120
+ c.to({ saved: true })
121
+ }
122
+ async put(c) { // PUT /user/:id
123
+ c.to({ updated: true })
124
+ }
125
+ async delete(c) { // DELETE /user/:id
126
+ c.to({ deleted: true })
127
+ }
128
+ }
129
+ module.exports = User
130
+ ```
131
+
132
+ #### 5.2 Custom Path Parameters
133
+
134
+ ```js
135
+ class User {
136
+ static param = '/:uid/profile' // overrides default /:id
137
+ static postParam = '/register' // POST /user/register
138
+
139
+ async post(c) {
140
+ c.ok('registered')
141
+ }
142
+ }
143
+ ```
144
+
145
+ #### 5.3 File-Specific Middleware
146
+
147
+ ```js
148
+ class User {
149
+ static __mid() {
150
+ return [
151
+ [require('../middleware/@auth'), { pre: true }],
152
+ require('../middleware/rate-limit')
153
+ ]
154
+ }
155
+ }
156
+ ```
157
+
158
+ #### 5.4 Homepage Controller
159
+
160
+ ```js
161
+ // controller/index.js
162
+ class Index {
163
+ async get(c) {
164
+ c.html('<h1>Welcome to Topbit</h1>')
165
+ }
166
+ }
167
+ module.exports = Index
168
+
169
+ // In Loader config:
170
+ new Loader({ homeFile: 'index.js' }).init(app)
171
+ ```
172
+
173
+ ---
174
+
175
+ ### 6. Middleware Writing Guide
176
+
177
+ #### 6.1 Class-Style Middleware (Recommended – file name starts with `@`)
178
+
179
+ ```js
180
+ // middleware/@auth.js
181
+ class Auth {
182
+ async middleware(c, next) {
183
+ if (!c.headers.token) return c.status(401).to('Token required')
184
+ c.user = { id: 1 }
185
+ await next(c)
186
+ }
187
+ }
188
+ module.exports = Auth
189
+ ```
190
+
191
+ #### 6.2 Global / Group Middleware via `__mid.js`
192
+
193
+ ```js
194
+ // controller/__mid.js (global) or controller/admin/__mid.js (group)
195
+ module.exports = [
196
+ { name: '@auth' }, // class middleware
197
+ { name: 'rate-limit', method: ['GET','POST'] }, // plain function
198
+ { middleware: async (c, next) => { // inline
199
+ console.log('global mid')
200
+ await next(c)
201
+ }, pre: true }
202
+ ]
203
+ ```
204
+
205
+ #### 6.3 File-Level Middleware (Most Precise)
206
+
207
+ ```js
208
+ // Inside any controller file
209
+ static __mid() {
210
+ return [
211
+ { name: '@vip-auth', pre: true },
212
+ { name: 'log', method: 'POST' }
213
+ ]
214
+ }
215
+ ```
216
+
217
+ ---
218
+
219
+ ### 7. Model Loading (modelLoader) Best Practice
220
+
221
+ ```js
222
+ new Loader({
223
+ modelLoader: async (service) => {
224
+ const glob = require('glob')
225
+ const path = require('path')
226
+ const files = glob.sync('model/**/*.js', { cwd: __dirname })
227
+
228
+ for (const f of files) {
229
+ const Model = require(path.resolve(__dirname, f))
230
+ const name = path.basename(f, '.js')
231
+ service[name + 'Model'] = new Model(service)
232
+ }
233
+ }
234
+ }).init(app)
235
+ ```
236
+
237
+ ---
238
+
239
+ ### 8. Naming & Safety Rules
240
+
241
+ - Folder and file names may only contain: `a-z 0-9 _ -` and must start with a letter
242
+ - No spaces, Chinese characters, uppercase letters, or special symbols
243
+ - Files/folders starting with `!` are automatically ignored
244
+ - Violation → red warning + skip loading
245
+
246
+ ---
247
+
248
+ ### 9. Advanced Tips Collection
249
+
250
+ | Need | Solution |
251
+ |---------------------------------|-------------------------------------------------------------------------------------------------------|
252
+ | Multiple API versions coexist | Use different `prePath` and create multiple Loader instances |
253
+ | Canary / gray release | `subgroup: ['v2']` + Nginx traffic split |
254
+ | Plugin system | Each plugin has its own folder → `new Loader({ appPath: './plugins/xxx' }).init(app)` |
255
+ | Hot reload (dev) | Set `multi: true` + watch files with chokidar and re-call `init()` |
256
+
257
+ ---
258
+
259
+ ### 10. Production-Grade Full Entry Example
260
+
261
+ ```js
262
+ // app.js (Ultimate production version)
263
+ 'use strict'
264
+ process.chdir(__dirname)
265
+
266
+ const Topbit = require('topbit')
267
+ const { Loader } = Topbit
268
+
269
+ const app = new Topbit({
270
+ debug: false,
271
+ http2: true,
272
+ allowHTTP1: true,
273
+ cert: '/etc/ssl/certs/fullchain.pem',
274
+ key: '/etc/ssl/private/privkey.pem',
275
+ globalLog: true,
276
+ logType: 'file',
277
+ logFile: '/var/log/topbit/access.log',
278
+ errorLogFile: '/var/log/topbit/error.log'
279
+ })
280
+
281
+ if (app.isWorker) {
282
+ new Loader({
283
+ prePath: '/api',
284
+ fileAsGroup: true,
285
+ optionsRoute: true,
286
+ modelLoader: async (svc) => {
287
+ svc.db = require('./lib/mysql-pool')
288
+ svc.redis = require('./lib/redis-client')
289
+ }
290
+ }).init(app)
291
+ }
292
+
293
+ app.sched('none')
294
+ app.autoWorker(32)
295
+ app.daemon(443, 8)
296
+ ```
297
+
298
+ ---
299
+
300
+ **You have now mastered the complete essence of TopbitLoader!**
301
+
302
+ Start using it today and you’ll find:
303
+ > Topbit + TopbitLoader = possibly the best developer experience + highest performance backend combination in the current Node.js ecosystem.
304
+
305
+ Happy coding and may your services fly!