mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 02:58:08 +08:00
feat: node name
This commit is contained in:
@@ -298,6 +298,8 @@ Use environment variables is recommended to avoid conflicts during upgrade.
|
||||
|
||||
`PROXY_URL_REGEX`: regex for url of enabling proxy, default to `.*`
|
||||
|
||||
`NODE_NAME`: node name, used for load balancing, identify current node
|
||||
|
||||
### User Authentication
|
||||
|
||||
Routes in `protected_route.js` will be protected using HTTP Basic Authentication.
|
||||
|
||||
@@ -370,6 +370,8 @@ RSSHub 支持 `memory` 和 `redis` 两种缓存方式
|
||||
|
||||
`LOGGER_LEVEL`: 指明输出到 console 和日志文件的日志的最大[等级](https://github.com/winstonjs/winston#logging-levels),默认 `info`
|
||||
|
||||
`NODE_NAME`: 节点名,用于负载均衡,识别当前节点
|
||||
|
||||
### 部分 RSS 模块配置
|
||||
|
||||
- pixiv 全部路由: [注册地址](https://accounts.pixiv.net/signup)
|
||||
|
||||
@@ -34,6 +34,7 @@ module.exports = {
|
||||
password: process.env.REDIS_PASSWORD || null,
|
||||
},
|
||||
},
|
||||
nodeName: process.env.NODE_NAME,
|
||||
pixiv: {
|
||||
client_id: 'MOBrBDS8blbauoSck0ZfDbtuzpyT',
|
||||
client_secret: 'lsACyCD94FhDUtGTXi3QzcFE2uU1hqtDaKeqrdwj',
|
||||
|
||||
@@ -6,6 +6,9 @@ const headers = {
|
||||
'Content-Type': 'application/xml; charset=utf-8',
|
||||
'Cache-Control': `public, max-age=${config.cache.routeExpire}`,
|
||||
};
|
||||
if (config.nodeName) {
|
||||
headers['RSSHub-Node'] = config.nodeName;
|
||||
}
|
||||
|
||||
module.exports = async (ctx, next) => {
|
||||
logger.info(`${ctx.url}, user IP: ${ctx.ips[0] || ctx.ip}`);
|
||||
|
||||
@@ -51,6 +51,12 @@ module.exports = async (ctx) => {
|
||||
ctx.body = art(path.resolve(__dirname, '../views/welcome.art'), {
|
||||
showDebug,
|
||||
debug: [
|
||||
config.nodeName
|
||||
? {
|
||||
name: '节点名',
|
||||
value: config.nodeName,
|
||||
}
|
||||
: null,
|
||||
{
|
||||
name: 'git hash',
|
||||
value: gitHash,
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
details {
|
||||
text-align: left;
|
||||
max-height: 400px;
|
||||
overflow: scroll;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
details::-webkit-scrollbar {
|
||||
@@ -91,10 +91,12 @@
|
||||
<details>
|
||||
<summary>debug</summary>
|
||||
{{ each debug }}
|
||||
{{ if $value }}
|
||||
<div class="debug-item">
|
||||
<span class="debug-key">{{ $value.name }}: </span>
|
||||
<span class="debug-value">{{@ $value.value }}</span>
|
||||
</div>
|
||||
{{ /if }}
|
||||
{{ /each }}
|
||||
</details>
|
||||
{{ /if }}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
process.env.NODE_NAME = 'mock';
|
||||
|
||||
const supertest = require('supertest');
|
||||
const { server } = require('../../lib/index');
|
||||
const request = supertest(server);
|
||||
@@ -34,6 +36,9 @@ describe('debug', () => {
|
||||
.html()
|
||||
.trim();
|
||||
switch (key) {
|
||||
case '节点名:':
|
||||
expect(value).toBe('mock');
|
||||
break;
|
||||
case 'git hash:':
|
||||
expect(value).toBe(gitHash);
|
||||
break;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
process.env.NODE_NAME = 'mock';
|
||||
|
||||
const supertest = require('supertest');
|
||||
const { server } = require('../../lib/index');
|
||||
const request = supertest(server);
|
||||
@@ -15,6 +17,6 @@ describe('header', () => {
|
||||
expect(response.headers['content-type']).toBe('application/xml; charset=utf-8');
|
||||
expect(response.headers['cache-control']).toBe(`public, max-age=${config.cache.routeExpire}`);
|
||||
expect(response.headers['last-modified']).toBe(response.text.match(/<lastBuildDate>(.*)<\/lastBuildDate>/)[1]);
|
||||
// expect(response.headers.etag).toBe('"b37-MORyrF0tJ8BFw0xLLZL/zBYAFPY"');
|
||||
expect(response.headers['rsshub-node']).toBe('mock');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user