Move static assets to shared location

This commit is contained in:
Alan Grainger
2026-10-06 09:28:53 +13:00
parent 255260ccb3
commit 9e6c00da35
12 changed files with 104 additions and 82 deletions
+16
View File
@@ -1,6 +1,10 @@
import { NextFunction, Request, Response } from 'express-serve-static-core'
import { resolve } from 'path'
import { getConfigOption } from './config/access'
/** Static assets both apps serve from core: pico, the Inter font, the favicon and theme.css. */
export const CORE_PUBLIC_DIR = resolve(__dirname, '../public')
/**
* Apply the response headers configured under `ipp.responseHeaders` to the
* given Response. Used by route handlers to attach the default Cache-Control
@@ -20,6 +24,18 @@ export function addNoStoreHeaders (res: Response): void {
res.set('Expires', '0')
}
/**
* A signal that aborts when the visitor's connection closes before the
* response has finished, so the request to Immich stops with it.
*/
export function abortOnClose (res: Response): AbortSignal {
const controller = new AbortController()
const onClose = () => { if (!res.writableFinished) controller.abort() }
res.once('close', onClose)
if (res.closed) onClose()
return controller.signal
}
/**
* Wrap an async route handler so a rejected promise is passed to Express's
* error chain (and on to `errorHandler`).