chanjs 2.0.1 → 2.0.2

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/README.md CHANGED
@@ -20,7 +20,6 @@ Chanjs 是一个基于 Express5+ 构建的轻量级 MVC 框架,完全使用 Ja
20
20
 
21
21
  ```code
22
22
  |- app
23
- |- config
24
23
  |- module
25
24
  |- module1
26
25
  |- controller
@@ -45,8 +44,12 @@ Chanjs 是一个基于 Express5+ 构建的轻量级 MVC 框架,完全使用 Ja
45
44
  |- service
46
45
  |- view
47
46
  |- router.js
48
- |- public
47
+ |- config
48
+ |- public
49
49
  |- index.js
50
+ |-.env.dev
51
+ |-.env.prd
52
+
50
53
  ```
51
54
 
52
55
  ### 初始化过程
package/common/global.js CHANGED
@@ -1,6 +1,9 @@
1
+
1
2
  import path from "path";
2
3
  import fs from "fs";
3
4
  import { pathToFileURL } from 'url'; // 新增顶部导入
5
+ import dotenv from "dotenv";
6
+
4
7
  const ROOT_PATH = process.cwd();
5
8
  const APP_PATH = path.join(ROOT_PATH, "app");
6
9
  const CONFIG_PATH = path.join(APP_PATH, "config");
@@ -18,6 +21,10 @@ global.__dirname = path.dirname(new URL(import.meta.url).pathname);
18
21
  //实现__filename
19
22
  global.__filename = new URL(import.meta.url).pathname;
20
23
 
24
+ //加载环境变量
25
+ const envFile = process.env.ENV_FILE || '.env.prd'
26
+ dotenv.config({ path: path.join(ROOT_PATH, envFile) })
27
+
21
28
  // app
22
29
  global.APP_PATH = APP_PATH;
23
30
  // config
package/index.js CHANGED
@@ -85,7 +85,6 @@ class Chan {
85
85
  setStatic(this.app, statics);
86
86
  Cors(this.app, cors);
87
87
  setHeader(this.app, { appName, version });
88
-
89
88
  }
90
89
 
91
90
  //数据库操作
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "chanjs",
4
- "version": "2.0.1",
4
+ "version": "2.0.2",
5
5
  "description": "chanjs基于express5 纯js研发的轻量级mvc框架。",
6
6
  "main": "index.js",
7
7
  "module": "index.js",
@@ -23,6 +23,7 @@
23
23
  "body-parser": "^2.2.0",
24
24
  "cookie-parser": "^1.4.7",
25
25
  "cors": "^2.8.5",
26
+ "dotenv": "^17.2.1",
26
27
  "dayjs": "^1.11.13",
27
28
  "express": "^5.1.0",
28
29
  "express-art-template": "^1.0.1",