Skip to content

Commit

Permalink
refactor: server
Browse files Browse the repository at this point in the history
  • Loading branch information
Soontao committed Nov 30, 2024
1 parent cb8b24a commit 4d51633
Show file tree
Hide file tree
Showing 1,653 changed files with 36 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
cache: 'npm'

- run: npm ci
- run: npm run test --workspaces
- run: npm test --if-present
env:
RSSHUB_TEST: true
REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}/
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"runtimeExecutable": "node",
"runtimeVersion": "20",
"outputCapture": "std",
"program": "${workspaceFolder}/lib/index.js",
"program": "${workspaceFolder}/packages/rss-server/index.js",
"envFile": "${workspaceFolder}/.env",
"env": {
"NODE_ENV": "dev",
Expand All @@ -35,7 +35,7 @@
"runtimeExecutable": "node",
"runtimeVersion": "20",
"outputCapture": "std",
"program": "${workspaceFolder}/lib/index.js",
"program": "${workspaceFolder}/packages/rss-server/index.js",
"envFile": "${workspaceFolder}/.env",
"env": {
"NODE_ENV": "dev",
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM m.daocloud.io/node:lts-slim

ARG npm_config_registry=https://registry.npmjs.org/
ENV npm_config_registry=${npm_config_registry}

Expand All @@ -15,8 +16,8 @@ COPY .npmrc package.json package-lock.json /app/

RUN npm ci --include prod

COPY lib /app/lib
COPY packages /app/packages

EXPOSE 1200

CMD ["node", "lib/index.js"]
CMD ["node", "packages/rss-server"]
16 changes: 2 additions & 14 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": [
"./lib/*"
]
}
},
"include": [
"./lib/**/*"
],
"exclude": [
"./lib/routes/**/*"
]
"include": ["./packages/**/*"],
"exclude": ["./packages/rss-server/routes/**/*"]
}
19 changes: 9 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
"node": ">=18",
"npm": ">=9"
},
"files": [
"lib"
],
"scripts": {
"start": "node lib/index.js",
"dev": "cross-env NODE_ENV=dev nodemon --inspect lib/index.js"
"start": "node packages/rss-server/index.js",
"dev": "cross-env NODE_ENV=dev nodemon --inspect packages/rss-server/index.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -108,6 +105,7 @@
"testEnvironment": "node"
},
"workspaces": [
"packages/rss-libs"
"packages/rss-libs",
"packages/rss-server"
]
}
6 changes: 3 additions & 3 deletions packages/rss-libs/test/middleware/access-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("access-control", () => {
const code = md5("/test/2" + key);
process.env.BLACKLIST = "/test/1,233.233.233.233";
process.env.ACCESS_KEY = key;
server = require("../../../../lib/index");
server = require("rss-server");
const request = supertest(server);

const response11 = await request.get("/test/1");
Expand Down Expand Up @@ -75,7 +75,7 @@ describe("access-control", () => {
const code = md5("/test/2" + key);
process.env.WHITELIST = "/test/1,233.233.233.233";
process.env.ACCESS_KEY = key;
server = require("../../../../lib/index");
server = require("rss-server");
const request = supertest(server);

const response01 = await request.get("/");
Expand Down Expand Up @@ -130,7 +130,7 @@ describe("access-control", () => {
const key = "1L0veRSSHub";
const code = md5("/test/2" + key);
process.env.ACCESS_KEY = key;
server = require("../../../../lib/index");
server = require("rss-server");
const request = supertest(server);

const response01 = await request.get("/");
Expand Down
6 changes: 3 additions & 3 deletions packages/rss-libs/test/middleware/anti-hotlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ afterEach(() => {
describe("anti-hotlink", () => {
it("template", async () => {
process.env.HOTLINK_TEMPLATE = "https://i3.wp.com/${host}${pathname}";
server = require("../../../../lib/index");
server = require("rss-server");
const request = supertest(server);

const response = await request.get("/test/complicated");
Expand All @@ -26,7 +26,7 @@ describe("anti-hotlink", () => {
});
it("url", async () => {
process.env.HOTLINK_TEMPLATE = "${protocol}//${host}${pathname}";
server = require("../../../../lib/index");
server = require("rss-server");
const request = supertest(server);

const response = await request.get("/test/complicated");
Expand All @@ -36,7 +36,7 @@ describe("anti-hotlink", () => {
});
it("no-template", async () => {
process.env.HOTLINK_TEMPLATE = "";
server = require("../../../../lib/index");
server = require("rss-server");
const request = supertest(server);

const response = await request.get("/test/complicated");
Expand Down
2 changes: 1 addition & 1 deletion packages/rss-libs/test/middleware/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
process.env.NODE_NAME = "mock";

const supertest = require("supertest");
const server = require("../../../../lib/index");
const server = require("rss-server");
const request = supertest(server);
const cheerio = require("cheerio");

Expand Down
2 changes: 1 addition & 1 deletion packages/rss-libs/test/middleware/header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process.env.NODE_NAME = "mock";

const supertest = require("supertest");
const server = require("../../../../lib/index");
const server = require("rss-server");
const request = supertest(server);
const config = require("../../config").value;
let etag;
Expand Down
2 changes: 1 addition & 1 deletion packages/rss-libs/test/middleware/onerror.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process.env.SENTRY = "https://[email protected]/1";

const supertest = require("supertest");
const server = require("../../../../lib/index");
const server = require("rss-server");
const request = supertest(server);

afterAll(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/rss-libs/test/middleware/parameter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const supertest = require("supertest");
const server = require("../../../../lib/index");
const server = require("rss-server");
const request = supertest(server);
const Parser = require("rss-parser");
const parser = new Parser();
Expand Down
2 changes: 1 addition & 1 deletion packages/rss-libs/test/middleware/template.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const supertest = require("supertest");
const server = require("../../../../lib/index");
const server = require("rss-server");
const request = supertest(server);
const Parser = require("rss-parser");
const parser = new Parser();
Expand Down
2 changes: 1 addition & 1 deletion packages/rss-libs/test/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process.env.SOCKET = "socket";

const supertest = require("supertest");
const server = require("../../../lib/index");
const server = require("rss-server");
const request = supertest(server);
const Parser = require("rss-parser");
const parser = new Parser();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/rss-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "rss-server"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 4d51633

Please sign in to comment.