mirror of
https://github.com/overleaf/overleaf.git
synced 2025-12-05 01:10:29 +00:00
Merge pull request #29471 from overleaf/revert-29369-mfb-from-joi-to-zod-clsi-cache
Revert "migrate from joi to zod CLSI-CACHE service" GitOrigin-RevId: 1846e5a1d990f7ff22982fc32277e24d69e9d1e0
This commit is contained in:
committed by
Copybot
parent
1720314726
commit
a88c307962
@@ -1,17 +0,0 @@
|
||||
const { isZodErrorLike, fromError } = require('zod-validation-error')
|
||||
/**
|
||||
* @typedef {import('express').ErrorRequestHandler} ErrorRequestHandler
|
||||
*/
|
||||
|
||||
const handleValidationError = [
|
||||
/** @type {ErrorRequestHandler} */
|
||||
(err, req, res, next) => {
|
||||
if (!isZodErrorLike(err)) {
|
||||
return next(err)
|
||||
}
|
||||
|
||||
res.status(400).json({ ...fromError(err), statusCode: 400 })
|
||||
},
|
||||
]
|
||||
|
||||
module.exports = { handleValidationError }
|
||||
@@ -2,12 +2,10 @@ const { ParamsError } = require('./Errors')
|
||||
const { z } = require('zod')
|
||||
const { zz } = require('./zodHelpers')
|
||||
const { validateReq } = require('./validateReq')
|
||||
const { handleValidationError } = require('./handleValidationError')
|
||||
|
||||
module.exports = {
|
||||
z,
|
||||
zz,
|
||||
validateReq,
|
||||
handleValidationError,
|
||||
ParamsError,
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
"dependencies": {
|
||||
"@overleaf/o-error": "*",
|
||||
"mongodb": "^6.12.0",
|
||||
"zod": "^4.1.8",
|
||||
"zod-validation-error": "^4.0.1"
|
||||
"zod": "^4.1.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.0.4",
|
||||
|
||||
5
package-lock.json
generated
5
package-lock.json
generated
@@ -541,8 +541,7 @@
|
||||
"dependencies": {
|
||||
"@overleaf/o-error": "*",
|
||||
"mongodb": "^6.12.0",
|
||||
"zod": "^4.1.8",
|
||||
"zod-validation-error": "^4.0.1"
|
||||
"zod": "^4.1.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.0.4",
|
||||
@@ -51425,9 +51424,9 @@
|
||||
"@overleaf/promise-utils": "*",
|
||||
"@overleaf/settings": "*",
|
||||
"@overleaf/stream-utils": "*",
|
||||
"@overleaf/validation-tools": "*",
|
||||
"body-parser": "^1.20.3",
|
||||
"bunyan": "^1.8.15",
|
||||
"celebrate": "^15.0.3",
|
||||
"express": "^4.21.2",
|
||||
"p-limit": "^3.1.0"
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ import express from 'express'
|
||||
import Settings from '@overleaf/settings'
|
||||
import logger from '@overleaf/logger'
|
||||
import metrics from '@overleaf/metrics'
|
||||
import Validation from './Validation.js'
|
||||
import csp, { removeCSPHeaders } from './CSP.mjs'
|
||||
import Router from '../router.mjs'
|
||||
import helmet from 'helmet'
|
||||
@@ -37,7 +38,6 @@ import os from 'node:os'
|
||||
import http from 'node:http'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import serveStaticWrapper from './ServeStaticWrapper.mjs'
|
||||
import { handleValidationError } from '@overleaf/validation-tools'
|
||||
|
||||
const { hasAdminAccess } = AdminAuthorizationHelper
|
||||
const sessionsRedisClient = UserSessionsRedis.client()
|
||||
@@ -356,17 +356,17 @@ const server = http.createServer(app)
|
||||
if (Settings.enabledServices.includes('api')) {
|
||||
logger.debug({}, 'providing api router')
|
||||
app.use(privateApiRouter)
|
||||
app.use(handleValidationError)
|
||||
app.use(Validation.errorMiddleware)
|
||||
app.use(ErrorController.handleApiError)
|
||||
}
|
||||
|
||||
if (Settings.enabledServices.includes('web')) {
|
||||
logger.debug({}, 'providing web router')
|
||||
app.use(publicApiRouter) // public API goes with web router for public access
|
||||
app.use(handleValidationError)
|
||||
app.use(Validation.errorMiddleware)
|
||||
app.use(ErrorController.handleApiError)
|
||||
app.use(webRouter)
|
||||
app.use(handleValidationError)
|
||||
app.use(Validation.errorMiddleware)
|
||||
app.use(ErrorController.handleError)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,22 @@ const {
|
||||
zz,
|
||||
ParamsError,
|
||||
} = require('@overleaf/validation-tools')
|
||||
const { isZodErrorLike, fromError } = require('zod-validation-error')
|
||||
|
||||
/**
|
||||
* @typedef {import('express').ErrorRequestHandler} ErrorRequestHandler
|
||||
*/
|
||||
|
||||
const errorMiddleware = [
|
||||
/** @type {ErrorRequestHandler} */
|
||||
(err, req, res, next) => {
|
||||
if (!isZodErrorLike(err)) {
|
||||
return next(err)
|
||||
}
|
||||
|
||||
res.status(400).json({ ...fromError(err), statusCode: 400 })
|
||||
},
|
||||
]
|
||||
|
||||
const validateReqWeb = (req, schema) => {
|
||||
try {
|
||||
@@ -21,6 +37,7 @@ const validateReqWeb = (req, schema) => {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
errorMiddleware,
|
||||
validateReq: validateReqWeb,
|
||||
z,
|
||||
zz,
|
||||
|
||||
Reference in New Issue
Block a user