Skip to content

Commit

Permalink
Remove req utils (#35695)
Browse files Browse the repository at this point in the history
  • Loading branch information
heiskr authored Mar 20, 2023
1 parent fa78387 commit fc28580
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 0 additions & 2 deletions middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
setDefaultFastlySurrogateKey,
setLanguageFastlySurrogateKey,
} from './set-fastly-surrogate-key.js'
import reqUtils from './req-utils.js'
import handleErrors from './handle-errors.js'
import handleInvalidPaths from './handle-invalid-paths.js'
import handleNextDataPath from './handle-next-data-path.js'
Expand Down Expand Up @@ -211,7 +210,6 @@ export default function (app) {
app.set('etag', false) // We will manage our own ETags if desired

// *** Config and context for redirects ***
app.use(reqUtils) // Must come before events
app.use(instrument(detectLanguage, './detect-language')) // Must come before context, breadcrumbs, find-page, handle-errors, homepages
app.use(asyncMiddleware(instrument(reloadTree, './reload-tree'))) // Must come before context
app.use(asyncMiddleware(instrument(context, './context'))) // Must come before early-access-*, handle-redirects
Expand Down
6 changes: 0 additions & 6 deletions middleware/req-utils.js

This file was deleted.

7 changes: 4 additions & 3 deletions src/events/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import addFormats from 'ajv-formats'
import { eventSchema, hydroNames } from './schema.js'
import catchMiddlewareError from '../../middleware/catch-middleware-error.js'
import { noCacheControl } from '../../middleware/cache-control.js'
import Hydro from './hydro.js'

const hydro = new Hydro()
const router = express.Router()
const ajv = new Ajv()
addFormats(ajv)
Expand All @@ -23,14 +25,13 @@ router.post(

res.json({})

if (req.hydro.maySend()) {
if (hydro.maySend()) {
try {
await req.hydro.publish(hydroNames[req.body.type], omit(req.body, OMIT_FIELDS))
await hydro.publish(hydroNames[req.body.type], omit(req.body, OMIT_FIELDS))
} catch (err) {
console.error('Failed to submit event to Hydro', err)
}
}
})
)

export default router

0 comments on commit fc28580

Please sign in to comment.