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
@@ -1,124 +1,106 @@
1
- import type { Request, Response } from "express";
2
-
3
- type BasicTypeDescriptor =
4
- | StringConstructor
5
- | NumberConstructor
6
- | BooleanConstructor
7
- | ObjectConstructor;
8
- export type TypeDescriptor = BasicTypeDescriptor | Array<any>;
9
-
10
- export interface TypeMapping {
11
- [key: string]:
12
- | TypeDescriptor
13
- | TypeMapping
14
- | Array<TypeDescriptor | TypeMapping>;
15
- }
16
-
17
- export type apiConfigTypeItem = {
18
- /** 接口名称 */
19
- name?: string;
20
- /** 接口描述 */
21
- des?: string;
22
- /** 接口请求方法 */
23
- methods?: "get" | "post" | "all";
24
- /** 请求头参数 */
25
- header?: {
26
- /** 参数名称 */
27
- name: string;
28
- /** 是否为空 */
29
- optional?: boolean;
30
- /** 请求头描述 */
31
- des?: string;
32
- /** 参数类型 */
33
- type: TypeDescriptor;
34
- }[];
35
- /** 是否启用token,默认关闭 */
36
- token?: boolean;
37
- /** 允许放行的权限,在启用token的情况下才有效 */
38
- permission?: string[];
39
- /** 请求类型 */
40
- "Content-Type"?:
41
- | "multipart/form-data"
42
- | "application/json"
43
- | "application/x-www-form-urlencoded";
44
- /** 请求示例 */
45
- example?: any;
46
- /** 响应示例 */
47
- resExample?: any;
48
- /** 效验数据格式 */
49
- validFormat?: TypeMapping | TypeDescriptor;
50
- /** 效验数据严格模式,默认不开启 */
51
- validFormatStrict?: boolean;
52
- /** 效验数据格式描述 */
53
- validFormatDes?:
54
- | string[]
55
- | {
56
- /** 字段名称 */
57
- name: string;
58
- /** 字段类型,不填会尝试从validFormat里取 */
59
- type?: TypeMapping | TypeDescriptor;
60
- /** 是否为空 */
61
- optional?: boolean;
62
- /** 字段描述 */
63
- des?: string;
64
- }[];
65
- };
66
- export type masRes = Response & {
67
- /** 响应数据 */
68
- return: (data: any, status?: any, code?: number, msg?: string) => void;
69
- token?: { data: any; _permission: string[] };
70
- };
71
- export type masReq = Request & {
72
- body: any;
73
- };
74
- export type configType = {
75
- /** 项目名称 */
76
- projectName: string;
77
- /** 端口号 */
78
- port: number;
79
- /** 是否开启接口文档 */
80
- apidoc: boolean;
81
- /** 接口文档配置 */
82
- apidocOptions?: {
83
- /** 默认留空即可 */
84
- baseUrl: "";
85
- };
86
- /** 是否允许跨域 */
87
- cors: boolean;
88
- logs: {
89
- /** 是否保存日志 */
90
- open: boolean;
91
- /** 是否打印访问日志 */
92
- debug: boolean;
93
- };
94
- /** ip请求限制 */
95
- apiLimit: {
96
- /** 是否开启 */
97
- open?: boolean;
98
- /** 同个 ip windowMs ms之内 */
99
- windowMs?: number;
100
- /** 最多max个请求 */
101
- max?: number; //
102
- };
103
- token: {
104
- /** 是否使用token */
105
- open: boolean;
106
- /** token秘钥 */
107
- pwd: string;
108
- /** 参数名 */
109
- headerParams: string;
110
- };
111
- /** debug延时时间 */
112
- debugTime?: number;
113
- /** 是否使用数据库 */
114
- useSql: boolean;
115
- /** 数据库信息 */
116
- sql: {
117
- host: string;
118
- user: string;
119
- password: string;
120
- database: string;
121
- };
122
- };
123
- export type apiCallback = Promise<(req: masReq, res: masRes) => void>;
124
- export type apiConfigType = { [key: string]: apiConfigTypeItem };
1
+ import type { Request, Response } from "express";
2
+
3
+ type BasicTypeDescriptor =
4
+ | StringConstructor
5
+ | NumberConstructor
6
+ | BooleanConstructor
7
+ | ObjectConstructor;
8
+ export type TypeDescriptor = BasicTypeDescriptor | Array<any>;
9
+
10
+ export interface TypeMapping {
11
+ [key: string]:
12
+ | TypeDescriptor
13
+ | TypeMapping
14
+ | Array<TypeDescriptor | TypeMapping>;
15
+ }
16
+
17
+ export type ApiConfigTypeItem = {
18
+ /** 接口名称 */
19
+ name?: string;
20
+ /** 接口描述 */
21
+ des?: string;
22
+ /** 接口请求方法 */
23
+ methods?: "get" | "post" | "all";
24
+ /** 请求头参数 */
25
+ header?: {
26
+ /** 参数名称 */
27
+ name: string;
28
+ /** 是否为空 */
29
+ optional?: boolean;
30
+ /** 请求头描述 */
31
+ des?: string;
32
+ /** 参数类型 */
33
+ type: TypeDescriptor;
34
+ }[];
35
+ /** 是否启用token,默认关闭 */
36
+ token?: boolean;
37
+ /** 允许放行的权限,在启用token的情况下才有效 */
38
+ permission?: string[];
39
+ /** 请求类型 */
40
+ "Content-Type"?:
41
+ | "multipart/form-data"
42
+ | "application/json"
43
+ | "application/x-www-form-urlencoded";
44
+ /** 请求示例 */
45
+ example?: any;
46
+ /** 响应示例 */
47
+ resExample?: any;
48
+ /** 效验数据格式 */
49
+ validFormat?: TypeMapping | TypeDescriptor;
50
+ /** 效验数据严格模式,默认不开启 */
51
+ validFormatStrict?: boolean;
52
+ /** 效验数据格式描述 */
53
+ validFormatDes?:
54
+ | string[]
55
+ | {
56
+ /** 字段名称 */
57
+ name: string;
58
+ /** 字段类型,不填会尝试从validFormat里取 */
59
+ type?: TypeMapping | TypeDescriptor;
60
+ /** 是否为空 */
61
+ optional?: boolean;
62
+ /** 字段描述 */
63
+ des?: string;
64
+ }[];
65
+ };
66
+ export type MasRes = Response & {
67
+ /** 响应数据 */
68
+ return: (data: any, status?: any, code?: number, msg?: string) => void;
69
+ token?: { data: any; _permission: string[] };
70
+ };
71
+ export type MasReq = Request & {
72
+ body: any;
73
+ };
74
+ export type ConfigType = {
75
+ /** 项目名称 */
76
+ projectName: string;
77
+ /** 端口号 */
78
+ port: number;
79
+ logs: {
80
+ /** 是否保存日志 */
81
+ open: boolean;
82
+ /** 是否打印访问日志 */
83
+ debug: boolean;
84
+ };
85
+ /** ip请求限制 */
86
+ apiLimit: {
87
+ /** 是否开启 */
88
+ open?: boolean;
89
+ /** 同个 ip windowMs ms之内 */
90
+ windowMs?: number;
91
+ /** 最多max个请求 */
92
+ max?: number; //
93
+ };
94
+ token: {
95
+ /** 是否使用token */
96
+ open: boolean;
97
+ /** token秘钥 */
98
+ pwd: string;
99
+ /** 参数名 */
100
+ headerParams: string;
101
+ };
102
+ /** debug延时时间 */
103
+ debugTime?: number;
104
+ };
105
+ export type ApiCallback = Promise<(req: MasReq, res: MasRes) => void>;
106
+ export type ApiConfigType = { [key: string]: ApiConfigTypeItem };
@@ -5,7 +5,7 @@ const apiLimit = (app: any, config?: { windowMs: number; max: number }) => {
5
5
  windowMs: config?.windowMs || 60 * 1000, // 1分钟
6
6
  max: config?.max || 20, // 最多10个请求
7
7
  // 当达到限制时调用的处理函数
8
- handler: function (req, res) {
8
+ handler: function (req, res: any) {
9
9
  res.status(502).end();
10
10
  },
11
11
  });
@@ -1,18 +1,18 @@
1
1
  import { state } from "../state";
2
- import getRouterInfo from "./getRouterInfo";
3
2
  import path from "path";
4
3
  import * as fs from "fs";
5
4
  import c from "ansi-colors";
6
- export default function createRouter(app) {
7
- const { Router, DIRNAME } = state;
5
+ export default function createRouter(app, apiDir: string) {
6
+ const { Router } = state;
8
7
  // 遍历api路由
9
8
  for (const item in Router) {
10
- let isExist = fs.existsSync(path.join(DIRNAME, "src", item) + ".ts");
9
+ const filePath = path.join(apiDir, "..", item) + ".ts";
10
+ let isExist = fs.existsSync(filePath);
11
11
  if (!isExist) {
12
12
  console.info(c.red(`${item} not found`));
13
13
  continue;
14
14
  }
15
- const apiFunc = require(path.join(DIRNAME, "src", item)).default;
15
+ const apiFunc = require(filePath).default;
16
16
  if (!apiFunc) {
17
17
  console.info(c.yellow(`${item} 没有导出函数,已跳过..`));
18
18
  } else {
@@ -5,23 +5,19 @@ import fs from "fs";
5
5
  import c from "ansi-colors";
6
6
  export default function getRouterInfo(apiDir: string, defaullConfigDir) {
7
7
  const apiConfig = {};
8
- const { DIRNAME } = state;
9
8
  const routerDir = readFilesRecursively(apiDir, "api");
10
- const defaullConfig = require(defaullConfigDir).default;
9
+ const defaullConfig = require(defaullConfigDir).config;
10
+
11
11
  // 遍历api路由
12
12
  for (const item of routerDir) {
13
- let isExist = fs.existsSync(path.join(DIRNAME, "src", item) + ".ts");
13
+ const filePath = path.join(apiDir, "..", item) + ".ts";
14
+ let isExist = fs.existsSync(filePath);
14
15
  if (!isExist) {
15
16
  console.info(c.red(`${item} not found`));
16
17
  continue;
17
18
  }
18
- const apiItemConfig = require(path.join(DIRNAME, "src", item)).config;
19
+ const apiItemConfig = require(filePath).config;
19
20
  apiConfig[item] = apiItemConfig || defaullConfig;
20
- // if (!apiFunc) {
21
- // console.info(c.yellow(`${item} 没有导出函数,已跳过..`));
22
- // } else {
23
- // apiFunc && app[Router[item].methods](item, apiFunc);
24
- // }
25
21
  }
26
22
  state.Router = apiConfig;
27
23
  return apiConfig;
@@ -1,5 +1,4 @@
1
1
  export function getType(obj): string {
2
- // "".toLocaleLowerCase
3
2
  return Object.prototype.toString
4
3
  .call(obj)
5
4
  .slice(8)
@@ -1,56 +1,56 @@
1
- const { decode, isJSON, encode } = require("./mas-encrypt.min.js");
2
- const getTimestamp = () => new Date().getTime();
3
- /**
4
- *
5
- * @param param0 token:解密的token,permission:效验的权限,只要有其中一个就可
6
- * @param key 解密密钥
7
- * @returns
8
- */
9
- const validToken = ({ token, permission = [] }, key = "8087") => {
10
- if (!token)
11
- return { msg: "没有传入token数据", errorCode: 0, status: 0, token };
12
- token = decode(token, key);
13
- if (!token) return { msg: "token数据错误", errorCode: 1, status: 0, token };
14
- // 鉴权
15
- if (permission.length != 0) {
16
- const tPermission = token._permission;
17
- if (!tPermission) {
18
- return { msg: "权限错误", errorCode: 2, status: 0, token };
19
- }
20
- if (tPermission.filter((value) => permission.includes(value)).length == 0) {
21
- return { msg: "权限错误", errorCode: 2, status: 0, token };
22
- }
23
- }
24
- // 过期时间
25
- if (token._masTime !== 0) {
26
- if (getTimestamp() > token._masTime)
27
- return { msg: "token过期", errorCode: 3, status: 0, token };
28
- }
29
-
30
- return { ...token, status: 1 };
31
- };
32
- const getErrorInfo = () => {
33
- return [
34
- { msg: "没有传入token数据", errorCode: 0, status: 0 },
35
- { msg: "token数据错误", errorCode: 1, status: 0 },
36
- { msg: "权限错误", errorCode: 2, status: 0 },
37
- { msg: "token过期", errorCode: 3, status: 0 },
38
- ];
39
- };
40
- /**
41
- *
42
- * @param param0 data:加密的数据,time:过期时间/s(为零则不会过期),permission:权限设置
43
- * @param key 加密密钥
44
- * @returns
45
- */
46
- function createToken(
47
- { data = null, time = 0, permission = [] } = {},
48
- key = "8087"
49
- ) {
50
- const token: any = {};
51
- token.data = data;
52
- permission.length != 0 && (token._permission = permission);
53
- time !== 0 && (token._masTime = time * 1000 + getTimestamp());
54
- return encode(token, key);
55
- }
56
- export { validToken, createToken };
1
+ const { decode, isJSON, encode } = require("./mas-encrypt.min.js");
2
+ const getTimestamp = () => new Date().getTime();
3
+ /**
4
+ *
5
+ * @param param0 token:解密的token,permission:效验的权限,只要有其中一个就可
6
+ * @param key 解密密钥
7
+ * @returns
8
+ */
9
+ const validToken = ({ token, permission = [] }, key = "8087") => {
10
+ if (!token)
11
+ return { msg: "没有传入token数据", errorCode: 0, status: 0, token };
12
+ token = decode(token, key);
13
+ if (!token) return { msg: "token数据错误", errorCode: 1, status: 0, token };
14
+ // 鉴权
15
+ if (permission.length != 0) {
16
+ const tPermission = token._permission;
17
+ if (!tPermission) {
18
+ return { msg: "权限错误", errorCode: 2, status: 0, token };
19
+ }
20
+ if (tPermission.filter((value) => permission.includes(value)).length == 0) {
21
+ return { msg: "权限错误", errorCode: 2, status: 0, token };
22
+ }
23
+ }
24
+ // 过期时间
25
+ if (token._masTime !== 0) {
26
+ if (getTimestamp() > token._masTime)
27
+ return { msg: "token过期", errorCode: 3, status: 0, token };
28
+ }
29
+
30
+ return { ...token, status: 1 };
31
+ };
32
+ const getErrorInfo = () => {
33
+ return [
34
+ { msg: "没有传入token数据", errorCode: 0, status: 0 },
35
+ { msg: "token数据错误", errorCode: 1, status: 0 },
36
+ { msg: "权限错误", errorCode: 2, status: 0 },
37
+ { msg: "token过期", errorCode: 3, status: 0 },
38
+ ];
39
+ };
40
+ /**
41
+ *
42
+ * @param param0 data:加密的数据,time:过期时间/s(为零则不会过期),permission:权限设置
43
+ * @param key 加密密钥
44
+ * @returns
45
+ */
46
+ function createToken(
47
+ { data = null, time = 0, permission = [] } = {},
48
+ key = "8087"
49
+ ) {
50
+ const token: any = {};
51
+ token.data = data;
52
+ permission.length != 0 && (token._permission = permission);
53
+ time !== 0 && (token._masTime = time * 1000 + getTimestamp());
54
+ return encode(token, key);
55
+ }
56
+ export { validToken, createToken };
@@ -1,8 +1,8 @@
1
- import { apiConfigType, masReq, masRes } from "..";
1
+ import { ApiConfigType, MasReq, MasRes } from "../typings/index";
2
2
  import { state } from "../state";
3
3
  import validType from "./validType";
4
- export default (req: masReq, res: masRes, next) => {
5
- const Router: apiConfigType = state.Router;
4
+ export default (req: any, res: MasRes, next) => {
5
+ const Router: ApiConfigType = state.Router;
6
6
  const routerObj = Router[req.path];
7
7
 
8
8
  if (routerObj) {
@@ -1,8 +1,8 @@
1
1
  import { state } from "../state";
2
- import { masReq, masRes, validToken } from "..";
2
+ import { MasReq, MasRes, validToken } from "..";
3
3
  import { getType } from "./masUtils";
4
4
 
5
- export default (req: masReq, res: any, next) => {
5
+ export default (req: any, res: any, next) => {
6
6
  const r = state.Router[req.path];
7
7
  const tokenConfig = state.config.token;
8
8
  if (getType(r?.permission) == "array") {
@@ -1,8 +1,8 @@
1
- import type { masReq, masRes } from "@/index";
1
+ import type { MasReq, MasRes } from "@/index";
2
2
  import masState from "@@/test/src/masState";
3
3
  import sqlform from "@@/test/src/sqlform.json";
4
4
 
5
- export default async (req: masReq, res: masRes) => {
5
+ export default async (req: MasReq, res: MasRes) => {
6
6
  const { sql } = masState;
7
7
  const sqlRes = await sql.use(sqlform.$form).delete(req.body).go();
8
8
  res.return(sqlRes);
@@ -1,8 +1,8 @@
1
- import type { masReq, masRes } from "@/index";
1
+ import type { MasReq, MasRes } from "@/index";
2
2
  import masState from "@@/test/src/masState";
3
3
  import sqlform from "@@/test/src/sqlform.json";
4
4
 
5
- export default async (req: masReq, res: masRes) => {
5
+ export default async (req: MasReq, res: MasRes) => {
6
6
  const { sql } = masState;
7
7
  const sqlRes = await sql.use(sqlform.$form).select(req.body).paging().go();
8
8
  res.return(sqlRes);
@@ -1,8 +1,8 @@
1
- import type { masReq, masRes } from "@/index";
1
+ import type { MasReq, MasRes } from "@/index";
2
2
  import masState from "@@/test/src/masState";
3
3
  import sqlform from "@@/test/src/sqlform.json";
4
4
 
5
- export default async (req: masReq, res: masRes) => {
5
+ export default async (req: MasReq, res: MasRes) => {
6
6
  const { sql } = masState;
7
7
  const sqlRes = await sql.use(sqlform.$form).set(req.body).go();
8
8
  res.return(sqlRes, sqlRes);
@@ -0,0 +1,8 @@
1
+ import type { ApiConfigTypeItem, MasReq, MasRes } from "@/index";
2
+ export const config: ApiConfigTypeItem = {
3
+ name: "默认接口",
4
+ methods: "all",
5
+ };
6
+ export default async (req: MasReq, res: MasRes) => {
7
+ res.return("hello mas-server!");
8
+ };
@@ -0,0 +1,29 @@
1
+ import { ConfigType } from "@/index";
2
+ export default <ConfigType>{
3
+ projectName: "mas-server",
4
+ port: 8087,
5
+ logs: {
6
+ open: true,
7
+ debug: false,
8
+ },
9
+ apiLimit: {
10
+ open: true,
11
+ windowMs: 60 * 1000,
12
+ max: 1000,
13
+ },
14
+ token: {
15
+ open: true,
16
+ pwd: "8087",
17
+ headerParams: "token",
18
+ },
19
+ debugTime: 100,
20
+ // useSql: false,
21
+ // sql: {
22
+ // host: "127.0.0.1",
23
+ // user: "root",
24
+ // password: "123456",
25
+ // database: "school",
26
+ // // database: "test",
27
+ // // password: "tx123456",
28
+ // },
29
+ };
@@ -1,5 +1,4 @@
1
- import { createSqlFormType } from "@/index";
2
- const createSqlFormData: createSqlFormType = {
1
+ const createSqlFormData = {
3
2
  testForm: [
4
3
  {
5
4
  key: "testA",
package/test/main.ts CHANGED
@@ -1,23 +1,26 @@
1
1
  import "module-alias/register";
2
- import { getApp, masReq, masRes } from "@/index";
3
- import masState from "./src/masState";
4
- import config from "./config/config";
5
-
6
- const app = getApp(__dirname, (app) => {
7
- // 数据库连接和express服务启动是异步进行的,如果数据库连接较慢,可能会出现调用接口访问不了数据库的情况
8
- app.use((req, res: masRes, next) => {
9
- if (config.useSql && !masState.sql) {
10
- res.return("数据库正在连接!", 0, 500);
11
- } else {
2
+ import { getApp, MasReq, MasRes } from "@/index";
3
+ import path from "path";
4
+ import config from "./config/serverConfig/config";
5
+ const app = getApp(
6
+ {
7
+ configPath: path.join(__dirname, "./config/serverConfig/config.ts"),
8
+ apisPath: path.join(__dirname, "./src/api/"),
9
+ defalutApiPath: path.join(__dirname, "./apiTemplate/defaultApi.ts"),
10
+ logPath: path.join(__dirname, "./logs"),
11
+ degbugPath: path.join(__dirname, "./src//debug.ts"),
12
+ },
13
+ (eapp) => {
14
+ eapp.use((req, res: MasRes, next) => {
12
15
  next();
13
- }
14
- });
15
- });
16
- app.all("/", (_req, res: masRes) => {
17
- res.return("default index");
18
- });
16
+ });
17
+ }
18
+ );
19
+ // app.all("/", (_req, res: MasRes) => {
20
+ // res.return("default index");
21
+ // });
19
22
  // 404兜底
20
- app.all("*", (_req: masReq, res: masRes) => {
23
+ app.all("*", (_req: MasReq, res: MasRes) => {
21
24
  res.return(404, 0, 404);
22
25
  });
23
26
  app.listen(8087, () => {
@@ -1,28 +1,28 @@
1
- import "module-alias/register";
2
- import { checkSqlKey, sqlInit, getsqlFormData, massql, sqlEnd } from "@/index";
3
- import * as fs from "fs";
4
- import * as path from "path";
5
- import config from "../config/config";
6
- import masState from "../src/masState";
7
- import c from "ansi-colors";
1
+ // import "module-alias/register";
2
+ // import { checkSqlKey, sqlInit, getsqlFormData, massql, sqlEnd } from "@/index";
3
+ // import * as fs from "fs";
4
+ // import * as path from "path";
5
+ // import config from "../config/config";
6
+ // import masState from "../src/masState";
7
+ // import c from "ansi-colors";
8
8
 
9
- // 数据库初始化
10
- (async () => {
11
- // mysql初始化
12
- if (config.useSql) {
13
- await sqlInit(config.sql);
14
- // 如果表没有update_time,create_time,is_delete三个字段,补上,放入masmysql的state中
15
- await checkSqlKey();
16
- // 比较入masmysql的state中的form,不一样重新生成生成sqlform,json
17
- getsqlFormData(path.join(__dirname, "/../src/sqlform.json"));
18
- if (process.argv[2] != "-end") {
19
- masState.sql = new massql();
20
- console.info(c.greenBright("mysql数据库连接成功!"));
21
- }
22
- if (process.argv[2] == "-end") {
23
- await sqlEnd();
24
- console.info(c.greenBright("初始化成功!"));
25
- }
26
- }
27
- })();
28
- export {};
9
+ // // 数据库初始化
10
+ // (async () => {
11
+ // // mysql初始化
12
+ // if (config.useSql) {
13
+ // await sqlInit(config.sql);
14
+ // // 如果表没有update_time,create_time,is_delete三个字段,补上,放入masmysql的state中
15
+ // await checkSqlKey();
16
+ // // 比较入masmysql的state中的form,不一样重新生成生成sqlform,json
17
+ // getsqlFormData(path.join(__dirname, "/../src/sqlform.json"));
18
+ // if (process.argv[2] != "-end") {
19
+ // masState.sql = new massql();
20
+ // console.info(c.greenBright("mysql数据库连接成功!"));
21
+ // }
22
+ // if (process.argv[2] == "-end") {
23
+ // await sqlEnd();
24
+ // console.info(c.greenBright("初始化成功!"));
25
+ // }
26
+ // }
27
+ // })();
28
+ // export {};
@@ -7,7 +7,7 @@ import {
7
7
  sqlEnd,
8
8
  getsqlFormDataType,
9
9
  } from "@/index";
10
- import config from "../config/config";
10
+ import config from "../config/serverConfig/config";
11
11
  import masState from "../src/masState";
12
12
  import * as fs from "fs";
13
13
  import * as path from "path";
@@ -1,5 +1,5 @@
1
1
  import "module-alias/register";
2
- import { createSqlForm } from "@/index";
3
- import createSqlFormData from "../config/createSqlFormData";
4
- import config from "../config/config";
5
- createSqlForm(config.sql, createSqlFormData);
2
+ // import { createSqlForm } from "@/index";
3
+ // import createSqlFormData from "../config/sqlConfig/createSqlFormData";
4
+ // import config from "../config/config";
5
+ // createSqlForm(config.sql, createSqlFormData);