@waline/vercel 1.30.2 → 1.30.4
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 +1 -1
- package/src/config/adapter.js +20 -8
- package/src/config/config.js +4 -2
- package/src/config/extend.js +6 -0
- package/src/controller/comment.js +1 -1
package/package.json
CHANGED
package/src/config/adapter.js
CHANGED
|
@@ -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
|
}
|
package/src/config/config.js
CHANGED
|
@@ -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) {
|
package/src/config/extend.js
CHANGED
|
@@ -4,6 +4,8 @@ const Mongo = require('think-mongo');
|
|
|
4
4
|
|
|
5
5
|
const { isNetlify, netlifyFunctionPrefix } = require('./netlify');
|
|
6
6
|
|
|
7
|
+
const isDeta = think.env === 'deta' || process.env.DETA_RUNTIME === 'true';
|
|
8
|
+
|
|
7
9
|
module.exports = [
|
|
8
10
|
Model(think.app),
|
|
9
11
|
Mongo(think.app),
|
|
@@ -22,6 +24,10 @@ module.exports = [
|
|
|
22
24
|
return `${protocol}://${host}${netlifyFunctionPrefix}`;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
if (isDeta) {
|
|
28
|
+
return `https://${host}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
return `${protocol}://${host}`;
|
|
26
32
|
},
|
|
27
33
|
async webhook(type, data) {
|