forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
203 lines (199 loc) · 6.85 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
require('dotenv').config();
let envs = process.env;
let value;
const calculateValue = () => {
const bilibili_cookies = {};
const twitter_tokens = {};
const email_config = {};
const discuz_cookies = {};
for (const name in envs) {
if (name.startsWith('BILIBILI_COOKIE_')) {
const uid = name.slice(16);
bilibili_cookies[uid] = envs[name];
} else if (name.startsWith('TWITTER_TOKEN_')) {
const id = name.slice(14);
twitter_tokens[id] = envs[name];
} else if (name.startsWith('EMAIL_CONFIG_')) {
const id = name.slice(13);
email_config[id] = envs[name];
} else if (name.startsWith('DISCUZ_COOKIE_')) {
const cid = name.slice(14);
discuz_cookies[cid] = envs[name];
}
}
value = {
isPackage: envs.IS_PACKAGE,
noLogfiles: envs.NO_LOGFILES,
connect: {
port: envs.PORT || 1200, // 监听端口
socket: envs.SOCKET || null, // 监听 Unix Socket, null 为禁用
},
cache: {
type: typeof envs.CACHE_TYPE === 'undefined' ? 'memory' : envs.CACHE_TYPE, // 缓存类型,支持 'memory' 和 'redis',设为空可以禁止缓存
routeExpire: parseInt(envs.CACHE_EXPIRE) || 5 * 60, // 路由缓存时间,单位为秒
contentExpire: parseInt(envs.CACHE_CONTENT_EXPIRE) || 1 * 60 * 60, // 不变内容缓存时间,单位为秒
},
ua: envs.UA || 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
listenInaddrAny: envs.LISTEN_INADDR_ANY || 1, // 是否允许公网连接,取值 0 1
requestRetry: parseInt(envs.REQUEST_RETRY) || 2, // 请求失败重试次数
// 是否显示 Debug 信息,取值 boolean 'false' 'key' ,取值为 'false' false 时永远不显示,取值为 'key' 时带上 ?debug=key 显示
debugInfo: envs.DEBUG_INFO || false,
disallowRobot: envs.DISALLOW_ROBOT !== '0' && envs.DISALLOW_ROBOT !== 'false',
titleLengthLimit: parseInt(envs.TITLE_LENGTH_LIMIT) || 150,
redis: {
url: envs.REDIS_URL || 'redis://localhost:6379/',
options: {
// 支持这些参数 https://github.com/NodeRedis/node_redis#options-object-properties
password: envs.REDIS_PASSWORD || null,
},
},
nodeName: envs.NODE_NAME,
suffix: envs.SUFFIX,
pixiv: {
username: envs.PIXIV_USERNAME,
password: envs.PIXIV_PASSWORD,
bypassCdn: envs.PIXIV_BYPASS_CDN !== '0' && envs.PIXIV_BYPASS_CDN !== 'false',
bypassCdnHostname: envs.PIXIV_BYPASS_HOSTNAME || 'public-api.secure.pixiv.net',
bypassCdnDoh: envs.PIXIV_BYPASS_DOH || 'https://1.1.1.1/dns-query',
},
fanbox: {
session: envs.FANBOX_SESSION_ID,
},
disqus: {
api_key: envs.DISQUS_API_KEY,
},
twitter: {
consumer_key: envs.TWITTER_CONSUMER_KEY,
consumer_secret: envs.TWITTER_CONSUMER_SECRET,
tokens: twitter_tokens,
},
youtube: {
key: envs.YOUTUBE_KEY,
},
telegram: {
token: envs.TELEGRAM_TOKEN,
},
github: {
access_token: envs.GITHUB_ACCESS_TOKEN,
},
authentication: {
name: envs.HTTP_BASIC_AUTH_NAME || 'usernam3',
pass: envs.HTTP_BASIC_AUTH_PASS || 'passw0rd',
},
bilibili: {
cookies: bilibili_cookies,
},
yuque: {
token: envs.YUQUE_TOKEN,
},
zhihu: {
cookies: envs.ZHIHU_COOKIES,
},
puppeteerWSEndpoint: envs.PUPPETEER_WS_ENDPOINT,
loggerLevel: envs.LOGGER_LEVEL || 'info',
proxyUri: envs.PROXY_URI,
proxy: {
protocol: envs.PROXY_PROTOCOL,
host: envs.PROXY_HOST,
port: envs.PROXY_PORT,
auth: envs.PROXY_AUTH,
url_regex: envs.PROXY_URL_REGEX || '.*',
},
allowOrigin: envs.ALLOW_ORIGIN,
blacklist: envs.BLACKLIST && envs.BLACKLIST.split(','),
whitelist: envs.WHITELIST && envs.WHITELIST.split(','),
allowLocalhost: envs.ALLOW_LOCALHOST,
accessKey: envs.ACCESS_KEY,
enableCluster: envs.ENABLE_CLUSTER,
email: {
config: email_config,
},
sentry: envs.SENTRY,
chuiniu: {
member: envs.CHUINIU_MEMBER,
},
weibo: {
app_key: envs.WEIBO_APP_KEY,
app_secret: envs.WEIBO_APP_SECRET,
redirect_url: envs.WEIBO_REDIRECT_URL,
},
fanfou: {
consumer_key: envs.FANFOU_CONSUMER_KEY,
consumer_secret: envs.FANFOU_CONSUMER_SECRET,
username: envs.FANFOU_USERNAME,
password: envs.FANFOU_PASSWORD,
},
lastfm: {
api_key: envs.LASTFM_API_KEY,
},
pkubbs: {
cookie: envs.PKUBBS_COOKIE,
},
nhentai: {
username: envs.NHENTAI_USERNAME,
password: envs.NHENTAI_PASSWORD,
},
discuz: {
cookies: discuz_cookies,
},
scihub: {
host: envs.SCIHUB_HOST || 'https://sci-hub.se/',
},
hotlink: {
template: envs.HOTLINK_TEMPLATE,
},
initium: {
username: envs.INITIUM_USERNAME,
password: envs.INITIUM_PASSWORD,
bearertoken: envs.INITIUM_BEARER_TOKEN,
iap_receipt: envs.INITIUM_IAP_RECEIPT,
},
btbyr: {
host: envs.BTBYR_HOST,
cookies: envs.BTBYR_COOKIE,
},
mastodon: {
apiHost: envs.MASTODON_API_HOST,
accessToken: envs.MASTODON_API_ACCESS_TOKEN,
acctDomain: envs.MASTODON_API_ACCT_DOMAIN,
},
xiaoyuzhou: {
device_id: envs.XIAOYUZHOU_ID,
refresh_token: envs.XIAOYUZHOU_TOKEN,
},
miniflux: {
instance: envs.MINIFLUX_INSTANCE || 'https://reader.miniflux.app',
token: envs.MINIFLUX_TOKEN || '',
},
nga: {
uid: envs.NGA_PASSPORT_UID,
cid: envs.NGA_PASSPORT_CID,
},
newrank: {
cookie: envs.NEWRANK_COOKIE,
},
ximalaya: {
token: envs.XIMALAYA_TOKEN,
},
game4399: {
cookie: envs.GAME_4399,
},
dida365: {
username: envs.DIDA365_USERNAME,
password: envs.DIDA365_PASSWORD,
},
scboy: {
token: envs.SCBOY_BBS_TOKEN,
},
};
};
calculateValue();
module.exports = {
set: (env) => {
envs = Object.assign(process.env, env);
calculateValue();
},
get value() {
return value;
},
};