Skip to content

Commit

Permalink
Port asset-preprocessing.js to TypeScript (#51382)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Jun 25, 2024
1 parent 1318dcf commit bc58017
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import type { Response, NextFunction } from 'express'

import type { ExtendedRequest } from '@/types'

// This middleware rewrites the URL of requests that contain the
// portion of `/cb-\d+/`.
// "cb" stands for "cache bust".
Expand All @@ -10,7 +14,11 @@

const regex = /\/cb-\d+\//

export default function assetPreprocessing(req, res, next) {
export default function assetPreprocessing(
req: ExtendedRequest,
res: Response,
next: NextFunction,
) {
if (req.path.startsWith('/assets/')) {
// We didn't use to have a rule about all image assets must be
// lower case. So we've exposed things like:
Expand Down
2 changes: 1 addition & 1 deletion src/frame/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import featuredLinks from '@/landings/middleware/featured-links.js'
import learningTrack from '@/learning-track/middleware/learning-track.js'
import next from './next.js'
import renderPage from './render-page.js'
import assetPreprocessing from '@/assets/middleware/asset-preprocessing.js'
import assetPreprocessing from '@/assets/middleware/asset-preprocessing'
import archivedAssetRedirects from '@/archives/middleware/archived-asset-redirects.js'
import favicons from './favicons.js'
import setStaticAssetCaching from '@/assets/middleware/static-asset-caching.js'
Expand Down

0 comments on commit bc58017

Please sign in to comment.