Skip to content

repo sync #24566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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