chanjs 2.0.0 → 2.0.1

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/index.js CHANGED
@@ -85,6 +85,7 @@ class Chan {
85
85
  setStatic(this.app, statics);
86
86
  Cors(this.app, cors);
87
87
  setHeader(this.app, { appName, version });
88
+
88
89
  }
89
90
 
90
91
  //数据库操作
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
2
  import favicon from "serve-favicon";
3
3
  export const setFavicon = (app) => {
4
- app.use(favicon(path.join(APP_PATH, "public/favicon.ico")));
4
+ app.use(favicon(path.join(ROOT_PATH, "public/favicon.ico")));
5
5
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "chanjs",
4
- "version": "2.0.0",
4
+ "version": "2.0.1",
5
5
  "description": "chanjs基于express5 纯js研发的轻量级mvc框架。",
6
6
  "main": "index.js",
7
7
  "module": "index.js",
@@ -14,7 +14,7 @@
14
14
  "nodejs mvc"
15
15
  ],
16
16
  "engines": {
17
- "node": ">=20.0.0"
17
+ "node": ">=22.18.0"
18
18
  },
19
19
  "author": "明空",
20
20
  "license": "ISC",
package/utils/db.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import knex from 'knex';
2
+
3
+
2
4
  export const db = function({
3
5
  client='mysql2',
4
6
  host='127.0.0.1',
package/utils/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {bindClass} from './bind.js'
2
2
  import {db} from './db.js'
3
3
  import {loaderSort,getPackage,loadConfig,loadController} from './loader.js'
4
+
4
5
  export {
5
6
  bindClass,
6
7
  db,
package/utils/loader.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { bindClass } from './bind.js';
3
4
 
4
5
  /**
5
6
  *
@@ -22,7 +23,7 @@ export const getPackage = async function(){
22
23
  }
23
24
 
24
25
  export const loadConfig = async function(){
25
- let config = await importFile('app/config/index.js')
26
+ let config = await importFile('config/index.js')
26
27
  return config;
27
28
  }
28
29
 
@@ -43,9 +44,11 @@ export const loadController = async function (moduleName) {
43
44
  }
44
45
 
45
46
  const files = fs.readdirSync(dir).filter(file => file.endsWith('.js'));
47
+
46
48
  for (const file of files) {
47
49
  const filePath = path.join(dir, file);
48
50
  const name = file.replace(/\.js$/i, ''); // 安全处理 .js 后缀
51
+
49
52
  try {
50
53
  const module = await importFile(filePath);
51
54
  controller[name] = { ...module};
package/utils/response.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export let success = (data) => {
2
2
  return {
3
3
  success: true,
4
- msg: "操作成功",
4
+ msg: "�����ɹ�",
5
5
  code: 200,
6
6
  data,
7
7
  };
@@ -10,7 +10,7 @@ export let success = (data) => {
10
10
  export let fail = (data, code = 201) => {
11
11
  return {
12
12
  success: false,
13
- msg: "操作失败",
13
+ msg: "����ʧ��",
14
14
  code,
15
15
  data,
16
16
  };
@@ -19,7 +19,7 @@ export let fail = (data, code = 201) => {
19
19
  export let err = (data = {}, code = 500) => {
20
20
  return {
21
21
  success: false,
22
- msg: "系统异常",
22
+ msg: "ϵͳ�쳣",
23
23
  code,
24
24
  data,
25
25
  };