chanjs 1.0.16 → 1.0.18
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 -1
- package/core/lib/config/config.js +0 -2
- package/core/lib/core.js +11 -5
- package/package.json +1 -1
package/core/chan.js
CHANGED
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
|
-
|
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
|
};
|