@waline/vercel 1.30.2 → 1.30.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waline/vercel",
3
- "version": "1.30.2",
3
+ "version": "1.30.3",
4
4
  "description": "vercel server for waline comment system",
5
5
  "keywords": [
6
6
  "waline",
@@ -31,12 +31,19 @@ const {
31
31
  SQLITE_DB,
32
32
  SQLITE_PREFIX,
33
33
  PG_DB,
34
+ POSTGRES_DATABASE,
34
35
  PG_HOST,
36
+ POSTGRES_HOST,
35
37
  PG_PASSWORD,
38
+ POSTGRES_PASSWORD,
36
39
  PG_PORT,
40
+ POSTGRES_PORT,
37
41
  PG_PREFIX,
42
+ POSTGRES_PREFIX,
38
43
  PG_USER,
44
+ POSTGRES_USER,
39
45
  PG_SSL,
46
+ POSTGRES_SSL,
40
47
  MONGO_AUTHSOURCE,
41
48
  MONGO_DB,
42
49
  MONGO_HOST,
@@ -64,7 +71,7 @@ if (MONGO_DB) {
64
71
  mongoOpt[key] = process.env[envKeys];
65
72
  }
66
73
  }
67
- } else if (PG_DB) {
74
+ } else if (PG_DB || POSTGRES_DATABASE) {
68
75
  type = 'postgresql';
69
76
  } else if (SQLITE_PATH) {
70
77
  type = 'sqlite';
@@ -74,6 +81,11 @@ if (MONGO_DB) {
74
81
  type = 'tidb';
75
82
  }
76
83
 
84
+ const isVercelPostgres =
85
+ type === 'postgresql' &&
86
+ POSTGRES_HOST &&
87
+ POSTGRES_HOST.endsWith('vercel-storage.com');
88
+
77
89
  exports.model = {
78
90
  type,
79
91
  common: {
@@ -100,15 +112,15 @@ exports.model = {
100
112
 
101
113
  postgresql: {
102
114
  handle: Postgresql,
103
- user: PG_USER,
104
- password: PG_PASSWORD,
105
- database: PG_DB,
106
- host: PG_HOST || '127.0.0.1',
107
- port: PG_PORT || '3211',
115
+ user: PG_USER || POSTGRES_USER,
116
+ password: PG_PASSWORD || POSTGRES_PASSWORD,
117
+ database: PG_DB || POSTGRES_DATABASE,
118
+ host: PG_HOST || POSTGRES_HOST || '127.0.0.1',
119
+ port: PG_PORT || POSTGRES_PORT || (isVercelPostgres ? '5432' : '3211'),
108
120
  connectionLimit: 1,
109
- prefix: PG_PREFIX || 'wl_',
121
+ prefix: PG_PREFIX || POSTGRES_PREFIX || 'wl_',
110
122
  ssl:
111
- PG_SSL == 'true'
123
+ (PG_SSL || POSTGRES_SSL) == 'true' || isVercelPostgres
112
124
  ? {
113
125
  rejectUnauthorized: false,
114
126
  }
@@ -7,7 +7,9 @@ const {
7
7
  TIDB_PASSWORD,
8
8
  SQLITE_PATH,
9
9
  PG_DB,
10
+ POSTGRES_DATABASE,
10
11
  PG_PASSWORD,
12
+ POSTGRES_PASSWORD,
11
13
  MONGO_DB,
12
14
  MONGO_PASSWORD,
13
15
  FORBIDDEN_WORDS,
@@ -53,9 +55,9 @@ if (LEAN_KEY) {
53
55
  } else if (MONGO_DB) {
54
56
  storage = 'mongodb';
55
57
  jwtKey = jwtKey || MONGO_PASSWORD;
56
- } else if (PG_DB) {
58
+ } else if (PG_DB || POSTGRES_DATABASE) {
57
59
  storage = 'postgresql';
58
- jwtKey = jwtKey || PG_PASSWORD;
60
+ jwtKey = jwtKey || PG_PASSWORD || POSTGRES_PASSWORD;
59
61
  } else if (SQLITE_PATH) {
60
62
  storage = 'sqlite';
61
63
  } else if (MYSQL_DB) {