Explicitly no cache on /api/events (#29549)
This commit is contained in:
@@ -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() : {})
|
||||
|
||||
Reference in New Issue
Block a user