mas-server 2.0.62 → 2.0.64

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.
@@ -5,8 +5,8 @@
5
5
  <link rel="icon" href="./favicon.ico">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>Vite App</title>
8
- <script type="module" crossorigin src="./assets/index-2d9f5a8a.js"></script>
9
- <link rel="stylesheet" href="./assets/index-b04b459f.css">
8
+ <script type="module" crossorigin src="./assets/index-2d9f5a8a.js"></script>
9
+ <link rel="stylesheet" href="./assets/index-b04b459f.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="app"></div>
@@ -7,8 +7,8 @@ const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
7
7
  const apiLimit = (app, config) => {
8
8
  // 创建一个速率限制器,限制每个IP地址在一分钟内最多可以发送10个请求
9
9
  const limiter = (0, express_rate_limit_1.default)({
10
- windowMs: (config === null || config === void 0 ? void 0 : config.windowMs) || 60 * 1000,
11
- max: (config === null || config === void 0 ? void 0 : config.max) || 20,
10
+ windowMs: (config === null || config === void 0 ? void 0 : config.windowMs) || 60 * 1000, // 1分钟
11
+ max: (config === null || config === void 0 ? void 0 : config.max) || 20, // 最多10个请求
12
12
  // 当达到限制时调用的处理函数
13
13
  handler: function (req, res) {
14
14
  res.status(502).end();
@@ -36,8 +36,8 @@ const getLogs = (app, dir) => {
36
36
  fs_1.default.existsSync(logDirectory) || fs_1.default.mkdirSync(logDirectory);
37
37
  // 创建一个循环日志流
38
38
  const accessLogStream = rfs.createStream("access.log", {
39
- size: "50M",
40
- interval: "1d",
39
+ size: "50M", // 单个文件的最大大小
40
+ interval: "1d", // 每天滚动日志
41
41
  path: logDirectory,
42
42
  });
43
43
  morgan_1.default.token("date", (req, res, tz) => {
@@ -12,7 +12,7 @@ const getTimestamp = () => new Date().getTime();
12
12
  const validToken = ({ token, permission = [] }, key = "8087") => {
13
13
  if (!token)
14
14
  return { msg: "没有传入token数据", errorCode: 0, status: 0, token };
15
- token = decode(token, key, 1);
15
+ token = decode(token, key);
16
16
  if (!token)
17
17
  return { msg: "token数据错误", errorCode: 1, status: 0, token };
18
18
  // 鉴权
@@ -52,6 +52,6 @@ function createToken({ data = null, time = 0, permission = [] } = {}, key = "808
52
52
  token.data = data;
53
53
  permission.length != 0 && (token._permission = permission);
54
54
  time !== 0 && (token._masTime = time * 1000 + getTimestamp());
55
- return encode(token, key, 1);
55
+ return encode(token, key);
56
56
  }
57
57
  exports.createToken = createToken;
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.default = (req, res, next) => {
13
13
  // req.fields && (req.body = req.fields);
14
14
  let right = true;
15
- res.return = (data, status = 1, code = 200, msg = "") => __awaiter(void 0, void 0, void 0, function* () {
15
+ res.return = (data_1, ...args_1) => __awaiter(void 0, [data_1, ...args_1], void 0, function* (data, status = 1, code = 200, msg = "") {
16
16
  if (!right)
17
17
  return;
18
18
  right = false;
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
- {
2
- "name": "mas-server",
3
- "version": "2.0.62",
4
- "description": "一款基于express面向中小型项目的后端框架",
5
- "main": "dist/index.js",
6
- "typings": "src/index.ts",
7
- "scripts": {
8
- "test": "npx ts-node ./test/scripts/beforeCreated.ts -end && npx ts-node ./test/scripts/run.ts",
9
- "testmon": "npx nodemon ./test/scripts/run.ts",
10
- "testTS": "npx nodemon ./test/test.ts",
11
- "createSql": "npx ts-node ./test/scripts/createSqlForm.ts",
12
- "createApi": "npx ts-node ./test/scripts/createApiFile.ts",
13
- "createApis": "npx ts-node ./test/scripts/createApis.ts",
14
- "init": "npx nodemon ./test/scripts/beforeCreated.ts -end",
15
- "gsft": "npx nodemon ./test/scripts/getSqlFormType.ts",
16
- "build": "node ./beforebuild.js && tsc --project ./tsconfig-build.json",
17
- "sync": "npm run build && npm publish && cnpm sync mas-server && explorer \"https://npmmirror.com/package/mas-server\""
18
- },
19
- "keywords": [],
20
- "author": "tingxi8087",
21
- "license": "ISC",
22
- "dependencies": {
23
- "@types/express": "^4.17.17",
24
- "ansi-colors": "^4.1.3",
25
- "axios": "^1.3.6",
26
- "cors": "^2.8.5",
27
- "express": "^4.18.2",
28
- "express-ip": "^1.0.4",
29
- "express-rate-limit": "^7.1.4",
30
- "fs-extra": "^11.1.1",
31
- "glob": "^10.3.1",
32
- "masmysql": "^2.0.56",
33
- "module-alias": "^2.2.2",
34
- "moment": "^2.29.4",
35
- "moment-timezone": "^0.5.44",
36
- "morgan": "^1.10.0",
37
- "mysql": "^2.18.1",
38
- "nodemon": "^2.0.22",
39
- "rotating-file-stream": "^3.1.1",
40
- "ts-node": "^10.9.1",
41
- "ts-node-dev": "^2.0.0",
42
- "typescript": "^5.0.4"
43
- },
44
- "_moduleAliases": {
45
- "@": "src/",
46
- "@@": "."
47
- },
48
- "devDependencies": {
49
- "@types/cors": "^2.8.13",
50
- "@types/express": "^4.17.17",
51
- "@types/moment": "^2.13.0"
52
- }
53
- }
1
+ {
2
+ "name": "mas-server",
3
+ "version": "2.0.64",
4
+ "description": "一款基于express面向中小型项目的后端框架",
5
+ "main": "dist/index.js",
6
+ "typings": "src/index.ts",
7
+ "scripts": {
8
+ "test": "npx ts-node ./test/scripts/beforeCreated.ts -end && npx ts-node ./test/scripts/run.ts",
9
+ "testmon": "npx nodemon ./test/scripts/run.ts",
10
+ "testTS": "npx nodemon ./test/test.ts",
11
+ "createSql": "npx ts-node ./test/scripts/createSqlForm.ts",
12
+ "createApi": "npx ts-node ./test/scripts/createApiFile.ts",
13
+ "createApis": "npx ts-node ./test/scripts/createApis.ts",
14
+ "init": "npx nodemon ./test/scripts/beforeCreated.ts -end",
15
+ "gsft": "npx nodemon ./test/scripts/getSqlFormType.ts",
16
+ "build": "node ./beforebuild.js && tsc --project ./tsconfig-build.json",
17
+ "sync": "npm run build && npm publish && cnpm sync mas-server && explorer \"https://npmmirror.com/package/mas-server\""
18
+ },
19
+ "keywords": [],
20
+ "author": "tingxi8087",
21
+ "license": "ISC",
22
+ "dependencies": {
23
+ "@types/express": "^4.17.17",
24
+ "ansi-colors": "^4.1.3",
25
+ "axios": "^1.3.6",
26
+ "cors": "^2.8.5",
27
+ "express": "^4.18.2",
28
+ "express-ip": "^1.0.4",
29
+ "express-rate-limit": "^7.1.4",
30
+ "fs-extra": "^11.1.1",
31
+ "glob": "^10.3.1",
32
+ "masmysql": "^2.0.56",
33
+ "module-alias": "^2.2.2",
34
+ "moment": "^2.29.4",
35
+ "moment-timezone": "^0.5.44",
36
+ "morgan": "^1.10.0",
37
+ "mysql": "^2.18.1",
38
+ "nodemon": "^2.0.22",
39
+ "rotating-file-stream": "^3.1.1",
40
+ "ts-node": "^10.9.1",
41
+ "ts-node-dev": "^2.0.0",
42
+ "typescript": "^5.0.4"
43
+ },
44
+ "_moduleAliases": {
45
+ "@": "src/",
46
+ "@@": "."
47
+ },
48
+ "devDependencies": {
49
+ "@types/cors": "^2.8.13",
50
+ "@types/express": "^4.17.17",
51
+ "@types/moment": "^2.13.0"
52
+ }
53
+ }
@@ -1 +1 @@
1
- import{_ as e}from"./index-2d9f5a8a.js";const r={};function t(c,n){return null}const o=e(r,[["render",t]]);export{o as default};
1
+ import{_ as e}from"./index-2d9f5a8a.js";const r={};function t(c,n){return null}const o=e(r,[["render",t]]);export{o as default};