mas-server 2.0.1 → 2.0.3
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/dist/apiDoc/assets/empty-907982e4.js +1 -0
- package/dist/apiDoc/assets/index-b56e6bc6.js +1414 -0
- package/dist/apiDoc/assets/index-bb16d834.css +6 -0
- package/dist/apiDoc/assets/jsoneditor-icons-45c98bf0.svg +749 -0
- package/dist/apiDoc/favicon.ico +0 -0
- package/dist/apiDoc/index.html +15 -0
- package/dist/index.js +139 -136
- package/dist/state.js +4 -4
- package/dist/typings/index.js +2 -2
- package/dist/utils/apiDoc.js +18 -18
- package/dist/utils/getLog.js +18 -18
- package/dist/utils/getRouteByApiSrc.js +54 -54
- package/dist/utils/mas-encrypt.min.js +3072 -0
- package/dist/utils/masUtils.js +12 -12
- package/dist/utils/meaToken.js +57 -57
- package/dist/utils/quickSend.js +32 -32
- package/dist/utils/readApi.js +50 -50
- package/dist/utils/validRouteData.js +37 -37
- package/dist/utils/validToken.js +24 -24
- package/dist/utils/validType.js +101 -101
- package/package.json +50 -48
- package/src/index.ts +3 -0
- package/src/utils/meaToken.ts +1 -1
- package/test/config/api.config.ts +2 -2
- package/test/config/config.ts +1 -1
- package/test/src/sqlform.json +12 -1
- package/test//345/276/205/345/274/200/345/217/221.md +3 -1
package/package.json
CHANGED
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mas-server",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "一款基于express面向中小型项目的后端框架",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"typings": "src/index.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"testdev": "npx ts-node-dev --transpile-only ./test/scripts/run.ts --respawn",
|
|
9
|
-
"test": "npx ts-node ./test/scripts/beforeCreated.ts -end && npx ts-node ./test/scripts/run.ts",
|
|
10
|
-
"testmon": "npx nodemon ./test/scripts/run.ts",
|
|
11
|
-
"testTS": "npx nodemon ./test/test.ts",
|
|
12
|
-
"createSql": "npx ts-node ./test/scripts/createSqlForm.ts",
|
|
13
|
-
"createApi": "npx ts-node ./test/scripts/createApiFile.ts",
|
|
14
|
-
"createApis": "npx ts-node ./test/scripts/createApis.ts",
|
|
15
|
-
"init": "npx nodemon ./test/scripts/beforeCreated.ts -end",
|
|
16
|
-
"gsft": "npx nodemon ./test/scripts/getSqlFormType.ts"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"@types/
|
|
48
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "mas-server",
|
|
3
|
+
"version": "2.0.3",
|
|
4
|
+
"description": "一款基于express面向中小型项目的后端框架",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "src/index.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"testdev": "npx ts-node-dev --transpile-only ./test/scripts/run.ts --respawn",
|
|
9
|
+
"test": "npx ts-node ./test/scripts/beforeCreated.ts -end && npx ts-node ./test/scripts/run.ts",
|
|
10
|
+
"testmon": "npx nodemon ./test/scripts/run.ts",
|
|
11
|
+
"testTS": "npx nodemon ./test/test.ts",
|
|
12
|
+
"createSql": "npx ts-node ./test/scripts/createSqlForm.ts",
|
|
13
|
+
"createApi": "npx ts-node ./test/scripts/createApiFile.ts",
|
|
14
|
+
"createApis": "npx ts-node ./test/scripts/createApis.ts",
|
|
15
|
+
"init": "npx nodemon ./test/scripts/beforeCreated.ts -end",
|
|
16
|
+
"gsft": "npx nodemon ./test/scripts/getSqlFormType.ts",
|
|
17
|
+
"build":"tsc",
|
|
18
|
+
"publish": "tsc && npm publish && cnpm sync cnpmcore"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [],
|
|
21
|
+
"author": "tingxi8087",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@types/express": "^4.17.17",
|
|
25
|
+
"ansi-colors": "^4.1.3",
|
|
26
|
+
"axios": "^1.3.6",
|
|
27
|
+
"cors": "^2.8.5",
|
|
28
|
+
"express": "^4.18.2",
|
|
29
|
+
"express-ip": "^1.0.4",
|
|
30
|
+
"fs-extra": "^11.1.1",
|
|
31
|
+
"glob": "^10.3.1",
|
|
32
|
+
"mas-encrypt": "^1.0.0",
|
|
33
|
+
"masmysql": "^2.0.4",
|
|
34
|
+
"module-alias": "^2.2.2",
|
|
35
|
+
"moment": "^2.29.4",
|
|
36
|
+
"mysql": "^2.18.1",
|
|
37
|
+
"nodemon": "^2.0.22",
|
|
38
|
+
"ts-node": "^10.9.1",
|
|
39
|
+
"ts-node-dev": "^2.0.0",
|
|
40
|
+
"typescript": "^5.0.4"
|
|
41
|
+
},
|
|
42
|
+
"_moduleAliases": {
|
|
43
|
+
"@": "src/",
|
|
44
|
+
"@@": "."
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/cors": "^2.8.13",
|
|
48
|
+
"@types/express": "^4.17.17",
|
|
49
|
+
"@types/moment": "^2.13.0"
|
|
50
|
+
}
|
|
49
51
|
}
|
package/src/index.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
import type { createSqlFormType, sqlForm } from "masmysql";
|
|
32
32
|
import apiDoc from "./utils/apiDoc";
|
|
33
33
|
import { createToken, validToken } from "./utils/meaToken";
|
|
34
|
+
import validType from "./utils/validType";
|
|
34
35
|
|
|
35
36
|
// =================================================================
|
|
36
37
|
export function getApp(
|
|
@@ -77,6 +78,7 @@ export function getApp(
|
|
|
77
78
|
}
|
|
78
79
|
// 数据效验
|
|
79
80
|
app.use(validRouteData);
|
|
81
|
+
// 使用接口文档
|
|
80
82
|
if (config.apidoc) {
|
|
81
83
|
app.use("/apidoc", express.static(path.join(__dirname, "/apiDoc")));
|
|
82
84
|
apiDoc(app);
|
|
@@ -121,6 +123,7 @@ export {
|
|
|
121
123
|
massql,
|
|
122
124
|
validToken,
|
|
123
125
|
createToken,
|
|
126
|
+
validType
|
|
124
127
|
};
|
|
125
128
|
export type {
|
|
126
129
|
masReq,
|
package/src/utils/meaToken.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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}]}};
|
|
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
3
|
export default apiConfig;
|
package/test/config/config.ts
CHANGED
package/test/src/sqlform.json
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"student": [
|
|
3
|
+
"name",
|
|
4
|
+
"age",
|
|
5
|
+
"des",
|
|
6
|
+
"create_time",
|
|
7
|
+
"update_time",
|
|
8
|
+
"is_delete",
|
|
9
|
+
"id",
|
|
10
|
+
"@!student"
|
|
11
|
+
]
|
|
12
|
+
}
|