Skip to content

Update dependencies and fix http-proxy-middleware compatibility #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand All @@ -16,7 +16,7 @@ jobs:

- name: Install dependencies
run: npm ci

- name: Test
run: npm run test

Expand Down
6 changes: 3 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export async function configure(startStamp) {
if (config.serveStore) {
const got = require('got');
const rewrite = require('express-urlrewrite');
const proxy = require('http-proxy-middleware');
const { createProxyMiddleware } = require('http-proxy-middleware');
const uploadServer = `http://${config.uploader.hostname || 'localhost'}:${config.uploader.port}`;
const downloadServer = `http://${config.downloader.hostname || 'localhost'}:${config.downloader.port}`;

Expand Down Expand Up @@ -197,8 +197,8 @@ export async function configure(startStamp) {
res.redirect(302, '/img/caps/avatarth.png');
});

app.use(['/upload', '/uploadava'], proxy({ target: uploadServer, logLevel: 'warn' }));
app.use('/download', proxy({ target: downloadServer, logLevel: 'warn' }));
app.use(['/upload', '/uploadava'], createProxyMiddleware({ target: uploadServer, logger }));
app.use('/download', createProxyMiddleware({ target: downloadServer, logger }));

// Seal store paths, ie request that achieve this handler will receive 404
app.get(/^\/(?:_a|_prn)(?:\/.*)$/, static404);
Expand Down
2 changes: 1 addition & 1 deletion controllers/__tests__/admin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('admin', () => {

await comment.create(data);

await expect(CommentN.count({ obj: news })).resolves.toBe(1);
await expect(CommentN.countDocuments({ obj: news })).resolves.toBe(1);
await expect(admin.deleteNews(news)).rejects.toThrow(new NoticeError(constants.NEWS_CONTAINS_COMMENTS));
});
});
Expand Down
4 changes: 2 additions & 2 deletions controllers/__tests__/comment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('comment', () => {
expect(result.comment.txt).toMatch(data.txt);
expect(result.comment.user).toMatch('user1');

await expect(CommentN.count({ obj: news })).resolves.toBe(1);
await expect(CommentN.countDocuments({ obj: news })).resolves.toBe(1);
});
});

Expand Down Expand Up @@ -93,7 +93,7 @@ describe('comment', () => {
await comment.create(data);

// Sanity check.
await expect(CommentN.count({ obj: news })).resolves.toBe(4);
await expect(CommentN.countDocuments({ obj: news })).resolves.toBe(4);

const comments = await comment.giveForUser({ login: 'user1', type: 'news' });

Expand Down
Loading