Skip to content

Commit

Permalink
Port fast-head.js to TypeScript (#51401)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Jun 25, 2024
1 parent 678402c commit f11c2f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/frame/middleware/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export default async function contextualize(

const context: Context = {}
req.context = context
console.log('CREATING CONTEXT')

req.context.process = { env: {} }

// define each context property explicitly for code-search friendliness
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { Response, NextFunction } from 'express'

import type { ExtendedRequest } from '@/types'
import { defaultCacheControl } from './cache-control.js'

export default function fastHead(req, res, next) {
export default function fastHead(req: ExtendedRequest, res: Response, next: NextFunction) {
if (!req.context) throw new Error('request is not contextualized')
const { context } = req
const { page } = context
if (page) {
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 @@ -56,7 +56,7 @@ import assetPreprocessing from '@/assets/middleware/asset-preprocessing'
import archivedAssetRedirects from '@/archives/middleware/archived-asset-redirects'
import favicons from './favicons.js'
import setStaticAssetCaching from '@/assets/middleware/static-asset-caching'
import fastHead from './fast-head.js'
import fastHead from './fast-head'
import fastlyCacheTest from './fastly-cache-test.js'
import trailingSlashes from './trailing-slashes.js'
import fastlyBehavior from './fastly-behavior.js'
Expand Down

0 comments on commit f11c2f0

Please sign in to comment.