@waline/vercel 1.18.7 → 1.19.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 (40) hide show
  1. package/__tests__/katex.spec.js +2 -0
  2. package/index.js +2 -0
  3. package/package.json +10 -10
  4. package/src/config/adapter.js +16 -0
  5. package/src/config/config.js +2 -1
  6. package/src/config/extend.js +6 -4
  7. package/src/controller/article.js +1 -0
  8. package/src/controller/comment.js +29 -0
  9. package/src/controller/db.js +54 -2
  10. package/src/controller/oauth.js +14 -8
  11. package/src/controller/rest.js +1 -0
  12. package/src/controller/token/2fa.js +4 -0
  13. package/src/controller/token.js +4 -0
  14. package/src/controller/user/password.js +3 -1
  15. package/src/controller/user.js +4 -1
  16. package/src/controller/verification.js +3 -0
  17. package/src/extend/controller.js +4 -0
  18. package/src/extend/think.js +8 -1
  19. package/src/locales/en.json +2 -2
  20. package/src/locales/zh-CN.json +2 -2
  21. package/src/locales/zh-TW.json +2 -2
  22. package/src/logic/base.js +15 -0
  23. package/src/logic/comment.js +5 -0
  24. package/src/logic/db.js +1 -0
  25. package/src/logic/token/2fa.js +1 -0
  26. package/src/logic/user.js +2 -0
  27. package/src/service/akismet.js +1 -0
  28. package/src/service/avatar.js +5 -0
  29. package/src/service/markdown/katex.js +2 -0
  30. package/src/service/markdown/mathCommon.js +5 -0
  31. package/src/service/markdown/mathjax.js +3 -0
  32. package/src/service/notify.js +109 -80
  33. package/src/service/storage/cloudbase.js +21 -0
  34. package/src/service/storage/deta.js +28 -0
  35. package/src/service/storage/github.js +77 -49
  36. package/src/service/storage/leancloud.js +42 -1
  37. package/src/service/storage/mongodb.js +17 -0
  38. package/src/service/storage/mysql.js +11 -0
  39. package/src/service/storage/postgresql.js +23 -2
  40. package/vanilla.js +1 -0
@@ -5,20 +5,37 @@ module.exports = class extends MySQL {
5
5
  return super.model(tableName.toLowerCase());
6
6
  }
7
7
 
8
- async select(...args) {
9
- const data = await super.select(...args);
8
+ async select(where, options = {}) {
9
+ const lowerWhere = {};
10
+
11
+ for (const i in where) {
12
+ lowerWhere[i.toLowerCase()] = where[i];
13
+ }
14
+
15
+ if (options && options.desc) {
16
+ options.desc = options.desc.toLowerCase();
17
+ }
18
+
19
+ if (Array.isArray(options.field)) {
20
+ options.field = options.field.map((field) => field.toLowerCase());
21
+ }
22
+
23
+ const data = await super.select(lowerWhere, options);
24
+
10
25
  return data.map(({ insertedat, createdat, updatedat, ...item }) => {
11
26
  const mapFields = {
12
27
  insertedAt: insertedat,
13
28
  createdAt: createdat,
14
29
  updatedAt: updatedat,
15
30
  };
31
+
16
32
  for (const field in mapFields) {
17
33
  if (!mapFields[field]) {
18
34
  continue;
19
35
  }
20
36
  item[field] = mapFields[field];
21
37
  }
38
+
22
39
  return item;
23
40
  });
24
41
  }
@@ -28,17 +45,20 @@ module.exports = class extends MySQL {
28
45
  .filter((key) => data[key])
29
46
  .forEach((key) => {
30
47
  const val = data[key];
48
+
31
49
  data[key.toLowerCase()] =
32
50
  val instanceof Date
33
51
  ? think.datetime(val, 'YYYY-MM-DD HH:mm:ss')
34
52
  : val;
35
53
  delete data[key];
36
54
  });
55
+
37
56
  return super.add(data);
38
57
  }
39
58
 
40
59
  async count(...args) {
41
60
  let result = await super.count(...args);
61
+
42
62
  try {
43
63
  if (Array.isArray(result)) {
44
64
  result.forEach((r) => {
@@ -50,6 +70,7 @@ module.exports = class extends MySQL {
50
70
  } catch (e) {
51
71
  console.log(e);
52
72
  }
73
+
53
74
  return result;
54
75
  }
55
76
  };
package/vanilla.js CHANGED
@@ -11,6 +11,7 @@ const instance = new Application({
11
11
  instance.run();
12
12
 
13
13
  let config = {};
14
+
14
15
  try {
15
16
  require('./config.js');
16
17
  } catch (e) {