mas-server 2.0.1 → 2.0.2

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/package.json CHANGED
@@ -1,49 +1,50 @@
1
- {
2
- "name": "mas-server",
3
- "version": "2.0.1",
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
- "keywords": [],
19
- "author": "tingxi8087",
20
- "license": "ISC",
21
- "dependencies": {
22
- "@types/express": "^4.17.17",
23
- "ansi-colors": "^4.1.3",
24
- "axios": "^1.3.6",
25
- "cors": "^2.8.5",
26
- "express": "^4.18.2",
27
- "express-ip": "^1.0.4",
28
- "fs-extra": "^11.1.1",
29
- "glob": "^10.3.1",
30
- "mas-encrypt": "^1.0.0",
31
- "masmysql": "^2.0.4",
32
- "module-alias": "^2.2.2",
33
- "moment": "^2.29.4",
34
- "mysql": "^2.18.1",
35
- "nodemon": "^2.0.22",
36
- "ts-node": "^10.9.1",
37
- "ts-node-dev": "^2.0.0",
38
- "typescript": "^5.0.4"
39
- },
40
- "_moduleAliases": {
41
- "@": "src/",
42
- "@@": "."
43
- },
44
- "devDependencies": {
45
- "@types/cors": "^2.8.13",
46
- "@types/express": "^4.17.17",
47
- "@types/moment": "^2.13.0"
48
- }
1
+ {
2
+ "name": "mas-server",
3
+ "version": "2.0.2",
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
+ },
19
+ "keywords": [],
20
+ "author": "tingxi8087",
21
+ "license": "ISC",
22
+ "dependencies": {
23
+ "@types/express": "^4.17.17",
24
+ "ansi-colors": "^4.1.3",
25
+ "axios": "^1.3.6",
26
+ "cors": "^2.8.5",
27
+ "express": "^4.18.2",
28
+ "express-ip": "^1.0.4",
29
+ "fs-extra": "^11.1.1",
30
+ "glob": "^10.3.1",
31
+ "mas-encrypt": "^1.0.0",
32
+ "masmysql": "^2.0.4",
33
+ "module-alias": "^2.2.2",
34
+ "moment": "^2.29.4",
35
+ "mysql": "^2.18.1",
36
+ "nodemon": "^2.0.22",
37
+ "ts-node": "^10.9.1",
38
+ "ts-node-dev": "^2.0.0",
39
+ "typescript": "^5.0.4"
40
+ },
41
+ "_moduleAliases": {
42
+ "@": "src/",
43
+ "@@": "."
44
+ },
45
+ "devDependencies": {
46
+ "@types/cors": "^2.8.13",
47
+ "@types/express": "^4.17.17",
48
+ "@types/moment": "^2.13.0"
49
+ }
49
50
  }
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(
@@ -121,6 +122,7 @@ export {
121
122
  massql,
122
123
  validToken,
123
124
  createToken,
125
+ validType
124
126
  };
125
127
  export type {
126
128
  masReq,
@@ -1,4 +1,4 @@
1
- const { decode, isJSON, encode } = require("./mas-encrypt.min");
1
+ const { decode, isJSON, encode } = require("./mas-encrypt.min.js");
2
2
  const getTimestamp = () => new Date().getTime();
3
3
  /**
4
4
  *
@@ -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;
@@ -23,7 +23,7 @@ export default <configType>{
23
23
  host: "127.0.0.1",
24
24
  user: "root",
25
25
  password: "123456",
26
- database: "test666",
26
+ database: "school",
27
27
  // database: "test",
28
28
  // password: "tx123456",
29
29
  },
@@ -1 +1,12 @@
1
- {"student":["id","name","age","des","update_time","is_delete","create_time","@!student"],"test11":["id","name","age","create_time","is_delete","update_time","@!test11"],"test22":["id","name","age","create_time","update_time","is_delete","@!test22"],"testform":["id","testA","numB","create_time","update_time","is_delete","@!testform"]}
1
+ {
2
+ "student": [
3
+ "name",
4
+ "age",
5
+ "des",
6
+ "create_time",
7
+ "update_time",
8
+ "is_delete",
9
+ "id",
10
+ "@!student"
11
+ ]
12
+ }
@@ -5,8 +5,10 @@ masmysql引入 (massql set方法开发) 完成
5
5
  接口文档生成 完成
6
6
  快捷创建接口
7
7
  生成sql类型 完成
8
+ 错误处理
8
9
  特别说明:
9
10
  get请求和请求头的number参数会被转为string
10
11
  接口改名配置丢失
11
12
  数据效验只支持对象形式
12
- 只能接收{}或[]
13
+ 只能接收{}或[]
14
+ cookie管理