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.
Files changed (74) hide show
  1. package/.temp/merge/validType.ts +98 -0
  2. package/beforebuild.js +3 -0
  3. package/dist/index.js +8 -47
  4. package/dist/utils/apiDoc.js +17 -2
  5. package/dist/utils/createRouter.js +51 -0
  6. package/dist/utils/getRouterInfo.js +34 -0
  7. package/dist/utils/mas-encrypt.min.js +1 -3072
  8. package/dist/utils/validRouteData.js +1 -1
  9. package/dist/utils/validToken.js +1 -1
  10. package/dist/utils/validType.js +0 -17
  11. package/package.json +50 -51
  12. package/src/index.ts +20 -24
  13. package/src/typings/index.ts +5 -5
  14. package/src/utils/apiDoc.ts +18 -2
  15. package/src/utils/createRouter.ts +22 -0
  16. package/src/utils/getRouterInfo.ts +28 -0
  17. package/src/utils/readApi.ts +0 -2
  18. package/src/utils/validRouteData.ts +1 -2
  19. package/src/utils/validToken.ts +1 -1
  20. package/src/utils/validType.ts +0 -17
  21. package/test/apiTemplate/api.temp.ts +8 -3
  22. package/test/config/config.ts +1 -1
  23. package/test/config/defaultApiConfig.ts +7 -0
  24. package/test/config/docNav.ts +0 -0
  25. package/test/main.ts +1 -0
  26. package/test/scripts/beforeCreated.ts +2 -41
  27. package/test/scripts/createApiFile.ts +0 -1
  28. package/test/scripts/createApis.ts +0 -48
  29. package/test/scripts/getSqlFormType.ts +2 -13
  30. package/test/src/api/example/ArrValid.ts +11 -0
  31. package/test/src/api/example/per.ts +34 -0
  32. package/test/src/api/example/tip.ts +9 -0
  33. package/test/src/api/example/validReqData.ts +85 -0
  34. package/test/src/api/index.ts +8 -1
  35. package/test/src/debug.ts +3 -50
  36. package/test/src/sqlform.json +1 -1
  37. package/test/test.ts +0 -12
  38. package/test//345/276/205/345/274/200/345/217/221.md +12 -6
  39. package/tsconfig-build.json +20 -0
  40. package/tsconfig.json +1 -3
  41. package/.temp/validType.ts +0 -96
  42. package/dist/apiDoc/assets/empty-a6de4920.js +0 -1
  43. package/dist/apiDoc/assets/index-be53fe8f.css +0 -6
  44. package/dist/apiDoc/assets/index-f9ab4187.js +0 -1427
  45. package/dist/apiDoc/assets/jsoneditor-icons-45c98bf0.svg +0 -749
  46. package/dist/apiDoc/favicon.ico +0 -0
  47. package/dist/apiDoc/index.html +0 -15
  48. package/dist/utils/getRouteByApiSrc.js +0 -54
  49. package/test/config/api.config.ts +0 -3
  50. package/test/config/api.key.ts +0 -14
  51. package/test/src/api/curd/student/del.ts +0 -9
  52. package/test/src/api/curd/student/get.ts +0 -9
  53. package/test/src/api/curd/student/set.ts +0 -9
  54. package/test/src/api/per.ts +0 -6
  55. package/test/src/api/person/del.ts +0 -4
  56. package/test/src/api/person/get.ts +0 -4
  57. package/test/src/api/person/set.ts +0 -4
  58. package/test/src/api/test.ts +0 -7
  59. package/test/src/api/validtest/boolArr.ts +0 -4
  60. package/test/typings/studentSF.ts +0 -6
  61. package/test/typings/test11SF.ts +0 -1
  62. package/test/typings/test22SF.ts +0 -1
  63. package/test/typings/testformSF.ts +0 -1
  64. /package/.temp/{logs/.keep → .keep} +0 -0
  65. /package/{src/utils → .temp}/getRouteByApiSrc.ts +0 -0
  66. /package/.temp/{a.ts → merge/a.ts} +0 -0
  67. /package/.temp/{as.ts → merge/as.ts} +0 -0
  68. /package/.temp/{b.ts → merge/b.ts} +0 -0
  69. /package/.temp/{i.js → merge/i.js} +0 -0
  70. /package/{test/typings → .temp/merge/logs}/.keep +0 -0
  71. /package/.temp/{test.ts → merge/test.ts} +0 -0
  72. /package/.temp/{validType copy.ts → merge/validType copy.ts} +0 -0
  73. /package/.temp/{validTypeOptimize.ts → merge/validTypeOptimize.ts} +0 -0
  74. /package/{test/scripts → .temp}/updateRouter.ts +0 -0
Binary file
@@ -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;
@@ -1,14 +0,0 @@
1
- export default {
2
- api: "接口",
3
- curd: "",
4
- student: "",
5
- del: "删除",
6
- get: "",
7
- set: "",
8
- index: "",
9
- per: "",
10
- person: "人",
11
- test: "",
12
- validtest: "",
13
- boolArr: "",
14
- };
@@ -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
- };
@@ -1,6 +0,0 @@
1
- import type { masReq, masRes } from "@/index";
2
- export default async (req: masReq, res: masRes) => {
3
- console.log(res.token);
4
-
5
- res.return("hello mas-server!");
6
- };
@@ -1,4 +0,0 @@
1
- import type { masReq, masRes } from "@/index";
2
- export default async (req: masReq, res: masRes) => {
3
- res.return([1, 2]);
4
- };
@@ -1,4 +0,0 @@
1
- import type { masReq, masRes } from "@/index";
2
- export default async (req: masReq, res: masRes) => {
3
- res.return([1, 2]);
4
- };
@@ -1,4 +0,0 @@
1
- import type { masReq, masRes } from "@/index";
2
- export default async (req: masReq, res: masRes) => {
3
- res.return("hello set!");
4
- };
@@ -1,7 +0,0 @@
1
- import type { masReq, masRes } from "@/index";
2
- export default async (req: masReq, res: masRes) => {
3
- console.log(req.body, "@body");
4
- console.log(req.query, "@query");
5
-
6
- res.return("hello test!");
7
- };
@@ -1,4 +0,0 @@
1
- import type { masReq, masRes } from "@/index";
2
- export default async (req: masReq, res: masRes) => {
3
- res.return("hello bool");
4
- };
@@ -1,6 +0,0 @@
1
- export type studentSF = {
2
- id?: number;
3
- name?: string;
4
- age?: number;
5
- des?: string;
6
- };
@@ -1 +0,0 @@
1
- export type test11SF = { id?: number; name?: string; age?: number };
@@ -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