Require Immich 3.x; code cleanup

This commit is contained in:
Alan Grainger
2026-10-06 09:23:57 +13:00
parent d03a77f691
commit 255260ccb3
33 changed files with 347 additions and 800 deletions
+1 -17
View File
@@ -1,7 +1,5 @@
import { NextFunction, Request, Response } from 'express-serve-static-core'
import { getConfigOption } from './config/access'
import { respondToInvalidRequest } from './invalidRequest'
import { log } from './utils/log'
/**
* Apply the response headers configured under `ipp.responseHeaders` to the
@@ -15,7 +13,7 @@ export function addResponseHeaders (res: Response): void {
})
}
/** Stop browsers and shared caches storing a response from a password-protected share. */
/** Stop browsers and shared caches storing a response: a password-protected share, or an error. */
export function addNoStoreHeaders (res: Response): void {
res.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate')
res.set('Pragma', 'no-cache')
@@ -31,17 +29,3 @@ export function asyncHandler (fn: (req: Request, res: Response, next: NextFuncti
fn(req, res, next).catch(next)
}
}
/**
* Terminal Express error middleware. Logs the error server-side, then applies the
* same privacy policy as any other invalid request.
*/
export function errorHandler (err: unknown, req: Request, res: Response, _next: NextFunction): void {
log.error('Error handling ' + req.method + ' ' + req.path + ' - ' +
(err instanceof Error ? (err.stack || err.message) : String(err)))
if (res.headersSent) {
res.end()
return
}
respondToInvalidRequest(res, 404, 'Unhandled error for ' + req.path)
}