Merge remote-tracking branch 'origin/master'

This commit is contained in:
DIYgod 2024-03-04 23:06:54 +08:00
commit d8ca915827
No known key found for this signature in database
4 changed files with 30 additions and 4 deletions

View File

@ -1,12 +1,18 @@
import { serve } from '@hono/node-server';
import logger from '@/utils/logger';
import { getLocalhostAddress } from '@/utils/common-utils';
import { config } from '@/config';
import app from '@/app';
const port = config.connect.port;
const hostIPList = getLocalhostAddress();
logger.info(`🎉 RSSHub is running on port ${port}! Cheers!`);
logger.info('💖 Can you help keep this open source project alive? Please sponsor 👉 https://docs.rsshub.app/support');
logger.info(`🔗 Local: 👉 http://localhost:${port}`);
for (const ip of hostIPList) {
logger.info(`🔗 Network: 👉 http://${ip}:${port}`);
}
const server = serve({
fetch: app.fetch,

View File

@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { toTitleCase, collapseWhitespace, convertDateToISO8601 } from '@/utils/common-utils';
import { toTitleCase, collapseWhitespace, convertDateToISO8601, getLocalhostAddress } from '@/utils/common-utils';
describe('common-utils', () => {
it('toTitleCase', () => {
@ -34,4 +34,8 @@ describe('common-utils', () => {
expect(collapseWhitespace('a string already collapsed')).toBe('a string already collapsed');
expect(collapseWhitespace(' \n a lot of whitespaces and \n\n\n\n linebreaks \n\n ')).toBe('a lot of whitespaces and linebreaks');
});
it('getLocalhostAddress', () => {
expect(getLocalhostAddress()).toBeInstanceOf(Array);
});
});

View File

@ -1,5 +1,6 @@
import { parseDate } from '@/utils/parse-date';
import title from 'title';
import os from 'os';
// convert a string into title case
const toTitleCase = (str: string) => title(str);
@ -31,4 +32,14 @@ const getSubPath = (ctx) => {
return subPath;
};
export { toTitleCase, collapseWhitespace, convertDateToISO8601, getSubPath };
const getLocalhostAddress = () => {
const interfaces = os.networkInterfaces();
const address = Object.keys(interfaces)
.flatMap((name) => interfaces[name] ?? [])
.filter((iface) => iface?.family === 'IPv4' && !iface.internal)
.map((iface) => iface?.address)
.filter(Boolean);
return address;
};
export { toTitleCase, collapseWhitespace, convertDateToISO8601, getSubPath, getLocalhostAddress };

View File

@ -38,9 +38,14 @@ export default function InstanceList(): JSX.Element {
maintainerUrl: 'https://www.pseudoyu.com',
}, {
url: 'https://rsshub.friesport.ac.cn',
location: '🇨🇳',
maintainer: '薯条港研究院',
maintainerUrl: 'https://space.bilibili.com/1690617042',
}, {
url: 'https://rsshub.friesport.ac.cn/us',
location: '🇺🇸',
maintainer: '思维悦动',
maintainerUrl: 'https://friesport.ac.cn',
maintainer: '薯条港研究院',
maintainerUrl: 'https://space.bilibili.com/1690617042',
}, {
url: 'https://rsshub.atgw.io',
location: '🇺🇸',