mas-server 2.0.64 → 3.0.0

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 (58) hide show
  1. package/.temp/getRouteByApiSrc.ts +2 -2
  2. package/.temp/updateRouter.ts +3 -3
  3. package/README.md +7 -1
  4. package/beforebuild.js +1 -2
  5. package/dist/index.js +12 -39
  6. package/dist/utils/createRouter.js +6 -5
  7. package/dist/utils/getRouterInfo.js +5 -10
  8. package/dist/utils/masUtils.js +1 -3
  9. package/dist/utils/meaToken.js +2 -2
  10. package/dist/utils/readApi.js +1 -1
  11. package/dist/utils/validType.js +1 -1
  12. package/package.json +53 -53
  13. package/src/index.ts +25 -72
  14. package/src/typings/index.ts +106 -124
  15. package/src/utils/apiLimit.ts +1 -1
  16. package/src/utils/createRouter.ts +5 -5
  17. package/src/utils/getRouterInfo.ts +5 -9
  18. package/src/utils/masUtils.ts +0 -1
  19. package/src/utils/meaToken.ts +56 -56
  20. package/src/utils/validRouteData.ts +3 -3
  21. package/src/utils/validToken.ts +2 -2
  22. package/test/apiTemplate/curd/del.ts +2 -2
  23. package/test/apiTemplate/curd/get.ts +2 -2
  24. package/test/apiTemplate/curd/set.ts +2 -2
  25. package/test/apiTemplate/defaultApi.ts +8 -0
  26. package/test/config/serverConfig/config.ts +29 -0
  27. package/test/config/{createSqlFormData.ts → sqlConfig/createSqlFormData.ts} +1 -2
  28. package/test/main.ts +20 -17
  29. package/test/scripts/beforeCreated.ts +27 -27
  30. package/test/scripts/createApis.ts +1 -1
  31. package/test/scripts/createSqlForm.ts +4 -4
  32. package/test/scripts/getSqlFormType.ts +1 -1
  33. package/test/src/api/example/ArrValid.ts +3 -4
  34. package/test/src/api/example/per.ts +5 -5
  35. package/test/src/api/example/tip.ts +3 -5
  36. package/test/src/api/example/validReqData.ts +3 -6
  37. package/test/src/api/index.ts +3 -6
  38. package/test/src/debug.ts +0 -5
  39. package/test/src/masState.ts +3 -3
  40. package/dist/apiDoc/assets/empty-3b5fe714.js +0 -1
  41. package/dist/apiDoc/assets/index-2d9f5a8a.js +0 -1427
  42. package/dist/apiDoc/assets/index-b04b459f.css +0 -6
  43. package/dist/apiDoc/assets/jsoneditor-icons-45c98bf0.svg +0 -749
  44. package/dist/apiDoc/favicon.ico +0 -0
  45. package/dist/apiDoc/index.html +0 -15
  46. package/dist/utils/apiDoc.js +0 -33
  47. package/src/apiDoc/assets/empty-3b5fe714.js +0 -1
  48. package/src/apiDoc/assets/index-2d9f5a8a.js +0 -1427
  49. package/src/apiDoc/assets/index-b04b459f.css +0 -6
  50. package/src/apiDoc/assets/jsoneditor-icons-45c98bf0.svg +0 -749
  51. package/src/apiDoc/favicon.ico +0 -0
  52. package/src/apiDoc/index.html +0 -15
  53. package/src/utils/apiDoc.ts +0 -34
  54. package/test/apiTemplate/api.temp.ts +0 -11
  55. package/test/config/config.ts +0 -36
  56. package/test/config/defaultApiConfig.ts +0 -7
  57. package/test/config/docNav.ts +0 -4
  58. package/test/src/sql/selectStudent.ts +0 -7
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-2d9f5a8a.js"></script>
9
- <link rel="stylesheet" href="./assets/index-b04b459f.css">
10
- </head>
11
- <body>
12
- <div id="app"></div>
13
-
14
- </body>
15
- </html>
@@ -1,34 +0,0 @@
1
- import { state } from "../state";
2
- import type { Express } from "express";
3
- import { masReq, masRes } from "..";
4
- export default (app: Express) => {
5
- const router = JSON.stringify(state.Router, (key, value) => {
6
- if (typeof value === "function") {
7
- return value.toString().replace(/function\s+(\w+)\(\)\s+\{.*\}/, "$1");
8
- }
9
- return value;
10
- });
11
- const newRouter = JSON.parse(router);
12
- // 有的描述没有类型,尝试从validFormat里取
13
- for (const key in newRouter) {
14
- const item = newRouter[key];
15
- if (item.validFormat && item.validFormatDes) {
16
- for (const validFormatDesItem of item.validFormatDes) {
17
- if (
18
- !validFormatDesItem.type &&
19
- item.validFormat[validFormatDesItem.name]
20
- ) {
21
- validFormatDesItem.type = item.validFormat[validFormatDesItem.name];
22
- } else if (!validFormatDesItem.type) {
23
- validFormatDesItem.type = "String";
24
- }
25
- }
26
- }
27
- }
28
- app.post("/apidoc/router", (req: masReq, res: masRes) => {
29
- res.return(newRouter);
30
- });
31
- app.post("/apidoc/cn", (req: masReq, res: masRes) => {
32
- res.return(state.apiCN);
33
- });
34
- };
@@ -1,11 +0,0 @@
1
- import type { apiConfigTypeItem, masReq, masRes } from "@/index";
2
- import masState from "@/masState";
3
-
4
- export const config: apiConfigTypeItem = {
5
- name: "默认接口",
6
- methods: "all",
7
- };
8
- export default async (req: masReq, res: masRes) => {
9
- const { sql } = masState;
10
- res.return("hello mas-server!");
11
- };
@@ -1,36 +0,0 @@
1
- import { configType } from "@/index";
2
- export default <configType>{
3
- projectName: "mas-server",
4
- port: 8087,
5
- apidoc: true,
6
- apidocOptions: {
7
- // iframe嵌套
8
- baseUrl: "",
9
- },
10
- cors: true,
11
- logs: {
12
- open: true,
13
- debug: false,
14
- },
15
- apiLimit: {
16
- open: true,
17
- windowMs: 60 * 1000,
18
- // windowMs: 60 * 1000,
19
- max: 1000,
20
- },
21
- token: {
22
- open: true,
23
- pwd: "8087",
24
- headerParams: "token",
25
- },
26
- useSql: false,
27
- debugTime: 100,
28
- sql: {
29
- host: "127.0.0.1",
30
- user: "root",
31
- password: "123456",
32
- database: "school",
33
- // database: "test",
34
- // password: "tx123456",
35
- },
36
- };
@@ -1,7 +0,0 @@
1
- import { apiConfigTypeItem } from "@/typings";
2
-
3
- const defaultApiConfig: apiConfigTypeItem = {
4
- name: "新建接口",
5
- methods: "all",
6
- };
7
- export default defaultApiConfig;
@@ -1,4 +0,0 @@
1
- export default {
2
- "/api/example": "响应示例",
3
- "/api": "接口",
4
- };
@@ -1,7 +0,0 @@
1
- import { massql } from "@/index";
2
-
3
- export const selectStudent = (id: number) => {
4
- const Tof = massql.escapeId;
5
- const Tok = massql.escape;
6
- return `SELECT * FROM ${Tof("student")} where id = ${Tok(id)}`;
7
- };