chanjs 1.0.2 → 1.0.4
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/core/chan.js +1 -6
- package/core/lib/core.js +1 -1
- package/package.json +7 -10
- package/app/config/config.base.js +0 -64
- package/app/config/config.dev.js +0 -12
- package/app/config/config.prd.js +0 -12
- package/app/config/index.js +0 -9
- package/app/extend/helper.js +0 -5
- package/app/module/api/controller/home.js +0 -39
- package/app/module/api/router.js +0 -8
- package/app/module/api/service/home.js +0 -15
- package/index.js +0 -9
package/core/chan.js
CHANGED
@@ -2,7 +2,7 @@ const express = require("express");
|
|
2
2
|
const config = require("./lib/config/config.js");
|
3
3
|
const path = require("path");
|
4
4
|
const fs = require("fs");
|
5
|
-
const core = require("
|
5
|
+
const core = require("./lib/core.js");
|
6
6
|
|
7
7
|
/**
|
8
8
|
* @description 基于express封装的mvc框架,遵循约定优于配置原则
|
@@ -41,12 +41,8 @@ class Chan {
|
|
41
41
|
const configPath = path.join(config.APP_PATH, "config/index.js");
|
42
42
|
if (fs.existsSync(configPath)) {
|
43
43
|
const config = require(configPath);
|
44
|
-
console.log('111----',Chan.config)
|
45
44
|
Chan.config = Object.assign(Chan.config, config);
|
46
|
-
console.log('222----',Chan.config)
|
47
45
|
}
|
48
|
-
|
49
|
-
|
50
46
|
}
|
51
47
|
|
52
48
|
// 加载扩展
|
@@ -59,7 +55,6 @@ class Chan {
|
|
59
55
|
for (let i = 0, file; i < controllers.length; i++) {
|
60
56
|
file = controllers[i];
|
61
57
|
const helper = require(path.join(extendPath, file));
|
62
|
-
|
63
58
|
const fileName = file.replace(".js", "");
|
64
59
|
Chan.helper[fileName] = helper;
|
65
60
|
}
|
package/core/lib/core.js
CHANGED
@@ -4,7 +4,7 @@ const favicon = require("serve-favicon");
|
|
4
4
|
const morgan = require("morgan");
|
5
5
|
const path = require("path");
|
6
6
|
|
7
|
-
const view = require("
|
7
|
+
const view = require("./middleware/view.js");
|
8
8
|
module.exports = async function (app) {
|
9
9
|
|
10
10
|
const { logger,APP_PATH, cookieKey, maxAge } = app.config;
|
package/package.json
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "chanjs",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.4",
|
4
4
|
"description": "Chanjs develops a lightweight MVC framework based on express pure JavaScript",
|
5
5
|
"main": "core/chan.js",
|
6
|
-
"
|
7
|
-
|
8
|
-
"clear": "node timer.js",
|
9
|
-
"prd": "pm2 start pm2.json"
|
10
|
-
},
|
6
|
+
"module":"core/chan.js",
|
7
|
+
"type": "module",
|
11
8
|
"keywords": [
|
12
|
-
"\"
|
9
|
+
"\"chanjs\"",
|
10
|
+
"\"express mvc\"",
|
11
|
+
"\"chancms\"",
|
12
|
+
"\"nodejs\""
|
13
13
|
],
|
14
14
|
"author": "\"明空\"",
|
15
15
|
"license": "ISC",
|
@@ -22,8 +22,5 @@
|
|
22
22
|
"knex": "^3.0.1",
|
23
23
|
"morgan": "^1.10.0",
|
24
24
|
"mysql2": "^3.6.2"
|
25
|
-
},
|
26
|
-
"devDependencies": {
|
27
|
-
"nodemon": "^3.0.1"
|
28
25
|
}
|
29
26
|
}
|
@@ -1,64 +0,0 @@
|
|
1
|
-
const path = require("path");
|
2
|
-
|
3
|
-
const config = {};
|
4
|
-
config.version = "v2.0.5";
|
5
|
-
config.appName = "禅悦cms";
|
6
|
-
config.port = '81';
|
7
|
-
config.versionTime = "2023-12-08";
|
8
|
-
config.author = "明空";
|
9
|
-
|
10
|
-
config.appRoot = path.join(__dirname, "../");
|
11
|
-
|
12
|
-
|
13
|
-
// cookie sign key
|
14
|
-
config.keys = "chanyue-cms_202301032044";
|
15
|
-
|
16
|
-
config.token = {
|
17
|
-
KEY: "chanyue-cms", // JSON WEB TOKEN KEY
|
18
|
-
TIME: "1d", // 失效时间 10
|
19
|
-
};
|
20
|
-
|
21
|
-
config.secret = {
|
22
|
-
key: "chanyue-cms", // md5 加盐
|
23
|
-
};
|
24
|
-
|
25
|
-
// 关闭csrf
|
26
|
-
config.security = {
|
27
|
-
csrf: {
|
28
|
-
enable: false,
|
29
|
-
},
|
30
|
-
};
|
31
|
-
|
32
|
-
// 配置上传
|
33
|
-
config.multipart = {
|
34
|
-
fileSize: "50mb",
|
35
|
-
mode: "stream",
|
36
|
-
whitelist: [
|
37
|
-
".jpg",
|
38
|
-
".jpeg",
|
39
|
-
".png",
|
40
|
-
".gif",
|
41
|
-
".zip",
|
42
|
-
".gz",
|
43
|
-
".tgz",
|
44
|
-
".gzip",
|
45
|
-
".mp3",
|
46
|
-
".mp4",
|
47
|
-
".avi",
|
48
|
-
],
|
49
|
-
fileExtensions: [".pdf", ".txt"], // 扩展几种上传的文件格式
|
50
|
-
};
|
51
|
-
|
52
|
-
// 模板配置
|
53
|
-
config.static = {
|
54
|
-
prefix: "/public/",
|
55
|
-
dynamic: true, // 如果当前访问的静态资源没有缓存,则缓存静态文件,和`preload`配合使用;
|
56
|
-
dir: ["app/public"],
|
57
|
-
maxAge: 0, // in prod env, 0 in other envs
|
58
|
-
buffer: false, // in prod env, false in other envs
|
59
|
-
preload: false,
|
60
|
-
};
|
61
|
-
|
62
|
-
config.views = [path.join(config.appRoot, `plugin/open/view`)];
|
63
|
-
|
64
|
-
module.exports = config;
|
package/app/config/config.dev.js
DELETED
package/app/config/config.prd.js
DELETED
package/app/config/index.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
const dev = require('./config.dev')
|
2
|
-
const prd = require('./config.prd')
|
3
|
-
const base = require('./config.base')
|
4
|
-
const config = {
|
5
|
-
'dev':dev,
|
6
|
-
'prd':prd
|
7
|
-
}
|
8
|
-
const env = process.env.NODE_ENV || 'dev'
|
9
|
-
module.exports = Object.assign({}, base, config[env]) // 合并配置
|
package/app/extend/helper.js
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
const Tea = require("../../../../core/chan");
|
2
|
-
const { service } = Tea.modules.api;
|
3
|
-
|
4
|
-
/**
|
5
|
-
*
|
6
|
-
* @param {*} req
|
7
|
-
* @param {*} res
|
8
|
-
* @param {*} next
|
9
|
-
*/
|
10
|
-
function index(req, res, next) {
|
11
|
-
try {
|
12
|
-
let data = service.home.index();
|
13
|
-
res.send(data);
|
14
|
-
} catch (error) {
|
15
|
-
console.log(error);
|
16
|
-
next(error);
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
|
21
|
-
/**
|
22
|
-
*
|
23
|
-
* @param {*} req
|
24
|
-
* @param {*} res
|
25
|
-
* @param {*} next
|
26
|
-
*/
|
27
|
-
function list(req, res, next) {
|
28
|
-
try {
|
29
|
-
let data = service.home.list();
|
30
|
-
res.send(data);
|
31
|
-
} catch (error) {
|
32
|
-
console.log(error);
|
33
|
-
next(error);
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
module.exports = {
|
38
|
-
index,list
|
39
|
-
};
|
package/app/module/api/router.js
DELETED