mas-server 2.0.46 → 2.0.51
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/.temp/merge/validType.ts +98 -0
- package/beforebuild.js +3 -0
- package/dist/index.js +8 -47
- package/dist/utils/apiDoc.js +17 -2
- package/dist/utils/createRouter.js +51 -0
- package/dist/utils/getRouterInfo.js +34 -0
- package/dist/utils/mas-encrypt.min.js +1 -3072
- package/dist/utils/validRouteData.js +1 -1
- package/dist/utils/validToken.js +1 -1
- package/dist/utils/validType.js +0 -17
- package/package.json +50 -51
- package/src/index.ts +20 -24
- package/src/typings/index.ts +5 -5
- package/src/utils/apiDoc.ts +18 -2
- package/src/utils/createRouter.ts +22 -0
- package/src/utils/getRouterInfo.ts +28 -0
- package/src/utils/readApi.ts +0 -2
- package/src/utils/validRouteData.ts +1 -2
- package/src/utils/validToken.ts +1 -1
- package/src/utils/validType.ts +0 -17
- package/test/apiTemplate/api.temp.ts +8 -3
- package/test/config/config.ts +1 -1
- package/test/config/defaultApiConfig.ts +7 -0
- package/test/config/docNav.ts +0 -0
- package/test/main.ts +1 -0
- package/test/scripts/beforeCreated.ts +2 -41
- package/test/scripts/createApiFile.ts +0 -1
- package/test/scripts/createApis.ts +0 -48
- package/test/scripts/getSqlFormType.ts +2 -13
- package/test/src/api/example/ArrValid.ts +11 -0
- package/test/src/api/example/per.ts +34 -0
- package/test/src/api/example/tip.ts +9 -0
- package/test/src/api/example/validReqData.ts +85 -0
- package/test/src/api/index.ts +8 -1
- package/test/src/debug.ts +3 -50
- package/test/src/sqlform.json +1 -1
- package/test/test.ts +0 -12
- package/test//345/276/205/345/274/200/345/217/221.md +12 -6
- package/tsconfig-build.json +20 -0
- package/tsconfig.json +1 -3
- package/.temp/validType.ts +0 -96
- package/dist/apiDoc/assets/empty-a6de4920.js +0 -1
- package/dist/apiDoc/assets/index-be53fe8f.css +0 -6
- package/dist/apiDoc/assets/index-f9ab4187.js +0 -1427
- package/dist/apiDoc/assets/jsoneditor-icons-45c98bf0.svg +0 -749
- package/dist/apiDoc/favicon.ico +0 -0
- package/dist/apiDoc/index.html +0 -15
- package/dist/utils/getRouteByApiSrc.js +0 -54
- package/test/config/api.config.ts +0 -3
- package/test/config/api.key.ts +0 -14
- package/test/src/api/curd/student/del.ts +0 -9
- package/test/src/api/curd/student/get.ts +0 -9
- package/test/src/api/curd/student/set.ts +0 -9
- package/test/src/api/per.ts +0 -6
- package/test/src/api/person/del.ts +0 -4
- package/test/src/api/person/get.ts +0 -4
- package/test/src/api/person/set.ts +0 -4
- package/test/src/api/test.ts +0 -7
- package/test/src/api/validtest/boolArr.ts +0 -4
- package/test/typings/studentSF.ts +0 -6
- package/test/typings/test11SF.ts +0 -1
- package/test/typings/test22SF.ts +0 -1
- package/test/typings/testformSF.ts +0 -1
- /package/.temp/{logs/.keep → .keep} +0 -0
- /package/{src/utils → .temp}/getRouteByApiSrc.ts +0 -0
- /package/.temp/{a.ts → merge/a.ts} +0 -0
- /package/.temp/{as.ts → merge/as.ts} +0 -0
- /package/.temp/{b.ts → merge/b.ts} +0 -0
- /package/.temp/{i.js → merge/i.js} +0 -0
- /package/{test/typings → .temp/merge/logs}/.keep +0 -0
- /package/.temp/{test.ts → merge/test.ts} +0 -0
- /package/.temp/{validType copy.ts → merge/validType copy.ts} +0 -0
- /package/.temp/{validTypeOptimize.ts → merge/validTypeOptimize.ts} +0 -0
- /package/{test/scripts → .temp}/updateRouter.ts +0 -0
package/dist/apiDoc/favicon.ico
DELETED
|
Binary file
|
package/dist/apiDoc/index.html
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<link rel="icon" href="./favicon.ico">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>Vite App</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-f9ab4187.js"></script>
|
|
9
|
-
<link rel="stylesheet" href="./assets/index-be53fe8f.css">
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<div id="app"></div>
|
|
13
|
-
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const readApi_1 = __importDefault(require("./readApi"));
|
|
7
|
-
const ansi_colors_1 = __importDefault(require("ansi-colors"));
|
|
8
|
-
function getRouteByApiSrc(apiSrc, apiConfig, apiKey) {
|
|
9
|
-
const routerArr = (0, readApi_1.default)(apiSrc, "api");
|
|
10
|
-
const newApiConfig = {};
|
|
11
|
-
apiConfig = Object.assign({}, apiConfig);
|
|
12
|
-
let isAdd = false;
|
|
13
|
-
for (let v of routerArr) {
|
|
14
|
-
if (!apiConfig[v]) {
|
|
15
|
-
isAdd = true;
|
|
16
|
-
console.info(ansi_colors_1.default.green(`新增接口 ${v}`));
|
|
17
|
-
newApiConfig[v] = {
|
|
18
|
-
name: "新建接口",
|
|
19
|
-
methods: "all",
|
|
20
|
-
des: "",
|
|
21
|
-
validFormat: null,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
newApiConfig[v] = apiConfig[v];
|
|
26
|
-
delete apiConfig[v];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (Object.keys(apiConfig).length != 0) {
|
|
30
|
-
console.info(ansi_colors_1.default.red(`删除接口 ${Object.keys(apiConfig)}`));
|
|
31
|
-
isAdd = true;
|
|
32
|
-
}
|
|
33
|
-
// 接口翻译
|
|
34
|
-
let newApiConfigArr = [];
|
|
35
|
-
for (let item in newApiConfig) {
|
|
36
|
-
for (let v of item.slice(1).split("/")) {
|
|
37
|
-
newApiConfigArr.push(v);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
newApiConfigArr = [...new Set(newApiConfigArr)];
|
|
41
|
-
apiKey = Object.assign({}, apiKey);
|
|
42
|
-
const newApiKey = {};
|
|
43
|
-
for (let v of newApiConfigArr) {
|
|
44
|
-
if (apiKey[v] === undefined) {
|
|
45
|
-
isAdd = true;
|
|
46
|
-
newApiKey[v] = "";
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
newApiKey[v] = apiKey[v];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return { newApiConfig, isAdd, newApiConfigArr, newApiKey };
|
|
53
|
-
}
|
|
54
|
-
exports.default = getRouteByApiSrc;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { apiConfigType } from "@/index";
|
|
2
|
-
const apiConfig: apiConfigType = {"/api/curd/student/del":{"name":"删除数据","methods":"all","des":"","validFormat":{"id":Number}},"/api/curd/student/get":{"name":"得到数据","methods":"all","des":"","validFormat":null},"/api/curd/student/set":{"name":"修改或添加数据","methods":"all","des":"","validFormat":null},"/api/index":{"name":"默认接口","methods":"post","des":"一个默认接口","validFormat":{"arr":[{"name":String,"age":Number}]},"header":[{"name":"token","type":String,"des":"token密钥"}],"validFormatDes":[{"name":"arr","type":{"arr":[{"name":String,"age":Number}]},"des":"学生数组"},{"name":"arg1","type":Number,"des":"可选参数","optional":true}],"example":{"arr":[{"name":"小明","age":18}]},"resExample":{"status":1,"data":"hello mas!","msg":""}},"/api/per":{"name":"新建接口","methods":"all","des":"","validFormat":null},"/api/person/del":{"name":"新建接口","methods":"all","des":"","validFormat":{"arr":[String]}},"/api/person/get":{"name":"新建接口","methods":"all","des":""},"/api/person/set":{"name":"新建接口","methods":"all","des":""},"/api/test":{"name":"新建接口","methods":"all","des":"","validFormat":null},"/api/validtest/boolArr":{"name":"新建接口","methods":"all","des":"","validFormat":[{"name":String}]}};
|
|
3
|
-
export default apiConfig;
|
package/test/config/api.key.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { masReq, masRes } from "@/index";
|
|
2
|
-
import masState from "@@/test/src/masState";
|
|
3
|
-
import sqlform from "@@/test/src/sqlform.json";
|
|
4
|
-
|
|
5
|
-
export default async (req: masReq, res: masRes) => {
|
|
6
|
-
const { sql } = masState;
|
|
7
|
-
const sqlRes = await sql.use(sqlform.student).delete(req.body).go();
|
|
8
|
-
res.return(sqlRes);
|
|
9
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { masReq, masRes } from "@/index";
|
|
2
|
-
import masState from "@@/test/src/masState";
|
|
3
|
-
import sqlform from "@@/test/src/sqlform.json";
|
|
4
|
-
|
|
5
|
-
export default async (req: masReq, res: masRes) => {
|
|
6
|
-
const { sql } = masState;
|
|
7
|
-
const sqlRes = await sql.use(sqlform.student).select(req.body).paging().go();
|
|
8
|
-
res.return(sqlRes);
|
|
9
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { masReq, masRes } from "@/index";
|
|
2
|
-
import masState from "@@/test/src/masState";
|
|
3
|
-
import sqlform from "@@/test/src/sqlform.json";
|
|
4
|
-
|
|
5
|
-
export default async (req: masReq, res: masRes) => {
|
|
6
|
-
const { sql } = masState;
|
|
7
|
-
const sqlRes = await sql.use(sqlform.student).set(req.body).go();
|
|
8
|
-
res.return(sqlRes, sqlRes);
|
|
9
|
-
};
|
package/test/src/api/per.ts
DELETED
package/test/src/api/test.ts
DELETED
package/test/typings/test11SF.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type test11SF = { id?: number; name?: string; age?: number };
|
package/test/typings/test22SF.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type test22SF = {id?:number;name?:string;age?:number;}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type testformSF = { id?: number; testA?: string; numB?: number };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|