mas-server 1.0.1 → 1.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/old ADDED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mas-server",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "一款基于express面向中小型项目的后端框架",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -17,7 +17,19 @@
17
17
  * @property {string} sql.password 数据库密码
18
18
  * @property {string} sql.database 数据库名称
19
19
  */
20
- const { $sqlForm } = require('masmysql');
20
+ /**
21
+ * @typedef {object} sqlForm
22
+ * @property {string} key - 字段名
23
+ * @property {"str" | "int" | "float"} type 类型
24
+ * @property {string} length 字符串长度,整数或浮点数可省略
25
+ * @property {boolean} notNull 是否不能为空,默认为false
26
+ */
27
+ /**
28
+ * @desc: 数据库一键建表规范
29
+ * @param {sqlForm[]} data
30
+ * @return {sqlForm[]} 返回配置
31
+ */
32
+ const $sqlForm = (data) => data
21
33
  module.exports = {
22
34
  /**
23
35
  * @desc: 数据库规范
@@ -1,18 +1,18 @@
1
1
  module.exports = (req, res, next) => {
2
- req.body = req.fields
3
- let right=true
2
+ req.body = req.fields;
3
+ let right = true;
4
4
  res.return = async (data, status = 1, code = 200) => {
5
- if(!right) return
6
- right=false
7
- if(!data){
8
- status=0
5
+ if (!right) return;
6
+ right = false;
7
+ if (!data) {
8
+ status = 0;
9
9
  }
10
- if (Number.isInteger(data)) data = data + ''
11
- if(data instanceof Promise) data = await data
10
+ if (Number.isInteger(data)) data = data + '';
11
+ if (data instanceof Promise) data = await data;
12
12
  res.status(code).send({
13
13
  status: status >= 1 ? 1 : 0,
14
14
  data: data ? data : null
15
- })
16
- }
17
- next()
18
- }
15
+ });
16
+ };
17
+ next();
18
+ };