1
0
mirror of synced 2025-12-23 21:07:12 -05:00

Explicitly no cache on /api/events (#29549)

This commit is contained in:
Kevin Heis
2022-08-02 11:22:17 -07:00
committed by GitHub
parent bf1c6a2dbe
commit 11267f2404

View File

@@ -4,19 +4,20 @@ import Ajv from 'ajv'
import addFormats from 'ajv-formats'
import { eventSchema, hydroNames } from '../../lib/schema-event.js'
import catchMiddlewareError from '../catch-middleware-error.js'
const OMIT_FIELDS = ['type']
const ajv = new Ajv()
addFormats(ajv)
import { cacheControlFactory } from '../cache-control.js'
const router = express.Router()
const noCacheControl = cacheControlFactory(0)
const ajv = new Ajv()
addFormats(ajv)
const OMIT_FIELDS = ['type']
router.post(
'/',
catchMiddlewareError(async function postEvents(req, res, next) {
catchMiddlewareError(async function postEvents(req, res) {
const isDev = process.env.NODE_ENV === 'development'
const fields = omit(req.body, '_csrf')
noCacheControl(res)
if (!ajv.validate(eventSchema, fields)) {
return res.status(400).json(isDev ? ajv.errorsText() : {})