chanjs 1.0.16 → 1.0.18

Sign up to get free protection for your applications and to get access to all the features.
package/core/chan.js CHANGED
@@ -116,7 +116,7 @@ class Chan {
116
116
 
117
117
  //解决跨域
118
118
  loadCors(){
119
- Chan.config?.cors && this.app.use(cors(Chan.config.cors));
119
+ Chan.config?.cors?.origin && this.app.use(cors(Chan.config.cors));
120
120
  }
121
121
 
122
122
  // 加载插件
@@ -17,8 +17,6 @@ let config = {
17
17
  },
18
18
  env:'dev',
19
19
  template:'default',
20
- cookieKey:'chanjs-2024-02-02-10:49',
21
- maxAge:'1d',
22
20
  views:[], //模板路径
23
21
  database:{
24
22
  client: "mysql2",
package/core/lib/core.js CHANGED
@@ -3,11 +3,10 @@ const cookieParser = require("cookie-parser");
3
3
  const favicon = require("serve-favicon");
4
4
  const morgan = require("morgan");
5
5
  const path = require("path");
6
-
7
6
  const view = require("./middleware/view.js");
8
7
  module.exports = async function (app) {
9
-
10
- const { logger,APP_PATH, cookieKey, maxAge,JSON_LIMIT } = app.config;
8
+ const { logger, APP_PATH, cookieKey, maxAge, JSON_LIMIT, appName, version } =
9
+ app.config;
11
10
  //日志
12
11
  app.use(morgan(logger.level));
13
12
 
@@ -18,7 +17,7 @@ module.exports = async function (app) {
18
17
  app.use(cookieParser(cookieKey));
19
18
 
20
19
  //解析接口 json & url
21
- app.use(express.json({ limit: JSON_LIMIT}));
20
+ app.use(express.json({ limit: JSON_LIMIT }));
22
21
  app.use(express.urlencoded({ extended: false }));
23
22
 
24
23
  //配置模板引擎
@@ -28,8 +27,15 @@ module.exports = async function (app) {
28
27
  app.use(
29
28
  "/public",
30
29
  express.static(path.join(APP_PATH, "public"), {
31
- maxAge:maxAge,
30
+ maxAge: maxAge,
32
31
  })
33
32
  );
34
33
 
34
+ //设置头信息
35
+ app.use((req, res, next) => {
36
+ res.setHeader("MVC", "Chanjs");
37
+ res.setHeader("X-Powered-By", appName);
38
+ res.setHeader(appName, version);
39
+ next();
40
+ });
35
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chanjs",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Chan.js基于express 纯js研发的轻量级mvc框架。",
5
5
  "main": "core/chan.js",
6
6
  "module": "core/chan.js",