Skip to content

Commit 65e7947

Browse files
authored
Migrating to express 5 (#6690)
* pMigrating to express 5 * Fixed export. * chore: bumped deps * chore: added express * chore: added express * chore: fixed admin ui
1 parent cca2c89 commit 65e7947

File tree

9 files changed

+151
-261
lines changed

9 files changed

+151
-261
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 2.5.0
2+
3+
### Notable enhancements and fixes
4+
- Updated to express 5.0.0. This is a major update to express that brings a lot of improvements and fixes.
5+
16
# 2.4.2
27

38
### Notable enhancements and fixes

pnpm-lock.yaml

Lines changed: 135 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ep.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@
9696
"socketio": "ep_etherpad-lite/node/handler/PadMessageHandler"
9797
}
9898
},
99-
{
100-
"name": "tests",
101-
"hooks": {
102-
"expressPreSession": "ep_etherpad-lite/node/hooks/express/tests"
103-
}
104-
},
10599
{
106100
"name": "admin",
107101
"hooks": {

src/node/hooks/express/admin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exports.expressCreateServer = (hookName: string, args: ArgsExpressType, cb: Func
2222
console.error('admin template not found, skipping admin interface. You need to rebuild it in /admin with pnpm run build-copy')
2323
return cb();
2424
}
25-
args.app.get('/admin/*', (req: any, res: any) => {
25+
args.app.get('/admin/{*filename}', (req: any, res: any) => {
2626
// extract URL path
2727
let pathname = path.join(ADMIN_PATH, req.url);
2828
pathname = path.normalize(pathname)

src/node/hooks/express/importexport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Functio
2525
});
2626

2727
// handle export requests
28-
args.app.use('/p/:pad/:rev?/export/:type', limiter);
29-
args.app.get('/p/:pad/:rev?/export/:type', (req:any, res:any, next:Function) => {
28+
args.app.use('/p/:pad{/:rev}/export/:type', limiter);
29+
args.app.get('/p/:pad{/:rev}/export/:type', (req:any, res:any, next:Function) => {
3030
(async () => {
3131
const types = ['pdf', 'doc', 'txt', 'html', 'odt', 'etherpad'];
3232
// send a 404 if we don't support this filetype

src/node/hooks/express/static.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {PartType} from "../../types/PartType";
66
const fs = require('fs').promises;
77
import {minify} from '../../utils/Minify';
88
import path from 'node:path';
9+
import {ArgsExpressType} from "../../types/ArgsExpressType";
910
const plugins = require('../../../static/js/pluginfw/plugin_defs');
1011
const settings = require('../../utils/Settings');
1112

@@ -30,16 +31,16 @@ const getTar = async () => {
3031
return tar;
3132
};
3233

33-
exports.expressPreSession = async (hookName:string, {app}:any) => {
34+
exports.expressPreSession = async (hookName:string, {app}:ArgsExpressType) => {
3435

3536
// Minify will serve static files compressed (minify enabled). It also has
3637
// file-specific hacks for ace/require-kernel/etc.
37-
app.all('/static/:filename(*)', minify);
38+
app.all('/static/*filename', minify);
3839

3940
// serve plugin definitions
4041
// not very static, but served here so that client can do
4142
// require("pluginfw/static/js/plugin-definitions.js");
42-
app.get('/pluginfw/plugin-definitions.json', (req: any, res:any, next:Function) => {
43+
app.get('/pluginfw/plugin-definitions.json', (_req, res) => {
4344
const clientParts = plugins.parts.filter((part: PartType) => part.client_hooks != null);
4445
const clientPlugins:MapArrayType<string> = {};
4546
for (const name of new Set(clientParts.map((part: PartType) => part.plugin))) {

src/node/hooks/express/tests.ts

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/node/utils/Minify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const compatPaths = {
146146
* @param res the Express response
147147
*/
148148
const _minify = async (req:any, res:any) => {
149-
let filename = req.params.filename;
149+
let filename = req.params.filename.join('/');
150150
try {
151151
filename = sanitizePathname(filename);
152152
} catch (err) {

src/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"cross-spawn": "^7.0.6",
3838
"ejs": "^3.1.10",
3939
"esbuild": "^0.25.8",
40-
"express": "4.21.2",
41-
"express-rate-limit": "^8.0.0",
40+
"express": "^5.1.0",
41+
"express-rate-limit": "^8.0.1",
4242
"express-session": "^1.18.2",
4343
"fast-deep-equal": "^3.1.3",
4444
"find-root": "1.1.0",
@@ -85,8 +85,8 @@
8585
"devDependencies": {
8686
"@playwright/test": "^1.54.1",
8787
"@types/async": "^3.2.24",
88+
"@types/express": "^5.0.0",
8889
"@types/cookie-parser": "^1.4.9",
89-
"@types/express": "^4.17.21",
9090
"@types/express-session": "^1.18.2",
9191
"@types/formidable": "^3.4.5",
9292
"@types/http-errors": "^2.0.5",

0 commit comments

Comments
 (0)