chanjs 1.0.28 → 1.0.30
Sign up to get free protection for your applications and to get access to all the features.
- package/README.en.md +100 -0
- package/README.md +2 -0
- package/core/chan.js +0 -1
- package/core/lib/config/config.js +5 -2
- package/package.json +3 -1
- package/publish.bat +4 -0
package/README.en.md
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# [中文](./README.md) | English
|
2
|
+
|
3
|
+
# <center>Chan.js MVC Framework</center>
|
4
|
+
|
5
|
+
Chan.js is a lightweight MVC framework developed in pure JavaScript based on Express. It embodies functional programming concepts, offering superior performance, clear code, and easy-to-follow processes that ensure high maintainability.
|
6
|
+
|
7
|
+
## 特性
|
8
|
+
|
9
|
+
- Built on top of Express
|
10
|
+
- Supports ES6 syntax
|
11
|
+
- Modular Design
|
12
|
+
- Supports multiple module routes
|
13
|
+
- Supports multiple module views
|
14
|
+
- Supports multiple module controllers
|
15
|
+
- Supports multiple module services
|
16
|
+
- Plugin-based architecture
|
17
|
+
- Lightweight (core code within 300 lines)
|
18
|
+
- Long-term maintenance
|
19
|
+
|
20
|
+
## Conventions Over Configuration
|
21
|
+
|
22
|
+
```code
|
23
|
+
|- app
|
24
|
+
|- config 配置
|
25
|
+
|- module 模块1
|
26
|
+
|- module1 模块1
|
27
|
+
|- controller 控制器
|
28
|
+
|- service 服务模型
|
29
|
+
|- view 视图模板
|
30
|
+
|- router.js 路由
|
31
|
+
|- module2 模块2
|
32
|
+
|- controller 控制器
|
33
|
+
|- service 服务模型
|
34
|
+
|- view 视图模板
|
35
|
+
|- router.js路由
|
36
|
+
|- extend 扩展
|
37
|
+
|- middleware 中间件
|
38
|
+
|- plugin 插件
|
39
|
+
|- plus-module1 插件1
|
40
|
+
|- controller 控制器
|
41
|
+
|- service 服务模型
|
42
|
+
|- view 视图模板
|
43
|
+
|- router.js 路由
|
44
|
+
|- module2 插件2
|
45
|
+
|- controller 控制器
|
46
|
+
|- service 服务模型
|
47
|
+
|- view 视图模板
|
48
|
+
|- router.js路由
|
49
|
+
|- public 静态文件
|
50
|
+
|- index.js
|
51
|
+
```
|
52
|
+
|
53
|
+
### Initialization Process
|
54
|
+
|
55
|
+
- Initialization
|
56
|
+
- Load configuration
|
57
|
+
- Load modules
|
58
|
+
- Load services
|
59
|
+
- Load controllers
|
60
|
+
- Load routers
|
61
|
+
- Load extensions
|
62
|
+
- Load plugins
|
63
|
+
- Load services
|
64
|
+
- Load controllers
|
65
|
+
- Load routers
|
66
|
+
- beforeStart() Hook to merge configurations from the database into the configuration
|
67
|
+
- run() Start the server
|
68
|
+
|
69
|
+
### Official Website
|
70
|
+
|
71
|
+
A CMS system developed with Chan.js
|
72
|
+
Website:<https://www.chancms.top>
|
73
|
+
|
74
|
+
### Highlights
|
75
|
+
|
76
|
+
- Configuration files
|
77
|
+
- Multi-module MVC structure
|
78
|
+
- Plugin MVC support
|
79
|
+
- CORS cross-origin configuration support
|
80
|
+
- MySQL database support
|
81
|
+
- Route control
|
82
|
+
- Art-template template engine
|
83
|
+
- Static resources management
|
84
|
+
- Cookie handling
|
85
|
+
- Logging capabilities
|
86
|
+
|
87
|
+
### 运行
|
88
|
+
|
89
|
+
```javascript
|
90
|
+
const Chanjs = require("chanjs");
|
91
|
+
const chan = new Chanjs();
|
92
|
+
// Load middleware
|
93
|
+
chan.beforeStart(fn);
|
94
|
+
// Scan modules
|
95
|
+
chan.start();
|
96
|
+
// Start the server
|
97
|
+
chan.run();
|
98
|
+
```
|
99
|
+
|
100
|
+
This framework is designed for developers who seek a balance between simplicity and functionality, providing a robust foundation for building web applications with ease.
|
package/README.md
CHANGED
package/core/chan.js
CHANGED
@@ -4,6 +4,8 @@ const path = require('path');
|
|
4
4
|
* @description 根目录
|
5
5
|
*/
|
6
6
|
const ROOT_PATH = process.cwd();
|
7
|
+
// 读取package.json文件
|
8
|
+
const {version='1.0.0',author='明空'} = require(path.join(ROOT_PATH, 'package.json'));
|
7
9
|
|
8
10
|
/**
|
9
11
|
* @description 程序目录
|
@@ -12,10 +14,11 @@ const APP_PATH = path.join(ROOT_PATH, 'app');
|
|
12
14
|
|
13
15
|
let config = {
|
14
16
|
JSON_LIMIT:"100kb",
|
15
|
-
SqlDebug:true,
|
16
17
|
logger : {
|
17
18
|
level: 'dev',
|
18
19
|
},
|
20
|
+
version,
|
21
|
+
author,
|
19
22
|
env:'dev',
|
20
23
|
template:'default',
|
21
24
|
views:[], //模板路径
|
@@ -30,7 +33,7 @@ let config = {
|
|
30
33
|
port: "3306",
|
31
34
|
user: "root",
|
32
35
|
password: "123456",
|
33
|
-
database: "
|
36
|
+
database: "chancms",
|
34
37
|
charset: "utf8mb4",
|
35
38
|
}
|
36
39
|
}
|
package/package.json
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "chanjs",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.30",
|
4
4
|
"description": "chanjs基于express 纯js研发的轻量级mvc框架。",
|
5
5
|
"main": "core/chan.js",
|
6
6
|
"module": "core/chan.js",
|
7
7
|
"keywords": [
|
8
8
|
"\"chanjs\"",
|
9
9
|
"\"express mvc\"",
|
10
|
+
"\"express mysql\"",
|
11
|
+
"\"express knex\"",
|
10
12
|
"\"chancms\"",
|
11
13
|
"\"nodejs\""
|
12
14
|
],
|
package/publish.bat
ADDED