Revert "deps: manual upgrade to express 5.1.0"

This commit is contained in:
Elian Doran
2025-04-11 16:51:42 +03:00
committed by GitHub
parent 3c5f5d2f76
commit d8964aee28
4 changed files with 265 additions and 213 deletions

View File

@@ -8,26 +8,9 @@ import type { Request, Response, Router } from "express";
import { safeExtractMessageAndStackFromError } from "../services/utils.js";
function handleRequest(req: Request, res: Response) {
// express puts content after first slash into 0 index element
// handle path from "*path" route wildcard
// in express v4, you could just add
// req.params.path + req.params[0], but with v5
// we get a split array that we have to join ourselves again
// @TriliumNextTODO: remove typecasting once express types are fixed
// they currently only treat req.params as string, while in reality
// it can also be a string[], when using wildcards
const splitPath = req.params.path as unknown as string[];
//const path = splitPath.map(segment => encodeURIComponent(segment)).join("/")
// naively join the "decoded" paths using a slash
// this is to mimick handleRequest behaviour
// as with the previous express v4.
// @TriliumNextTODO: using something like =>
// splitPath.map(segment => encodeURIComponent(segment)).join("/")
// might be safer
const path = splitPath.join("/")
const path = req.params.path + req.params[0];
const attributeIds = sql.getColumn<string>("SELECT attributeId FROM attributes WHERE isDeleted = 0 AND type = 'label' AND name IN ('customRequestHandler', 'customResourceProvider')");
@@ -87,7 +70,7 @@ function handleRequest(req: Request, res: Response) {
function register(router: Router) {
// explicitly no CSRF middleware since it's meant to allow integration from external services
router.all("/custom/*path", (req: Request, res: Response, _next) => {
router.all("/custom/:path*", (req: Request, res: Response, _next) => {
cls.namespace.bindEmitter(req);
cls.namespace.bindEmitter(res);

View File

@@ -236,7 +236,7 @@ function register(app: express.Application) {
apiRoute(GET, "/api/options", optionsApiRoute.getOptions);
// FIXME: possibly change to sending value in the body to avoid host of HTTP server issues with slashes
apiRoute(PUT, "/api/options/:name/:value", optionsApiRoute.updateOption);
apiRoute(PUT, "/api/options/:name/:value*", optionsApiRoute.updateOption);
apiRoute(PUT, "/api/options", optionsApiRoute.updateOptions);
apiRoute(GET, "/api/options/user-themes", optionsApiRoute.getUserThemes);
apiRoute(GET, "/api/options/codeblock-themes", optionsApiRoute.getSyntaxHighlightingThemes);