|
@@ -7,11 +7,7 @@ import Settings from '@overleaf/settings'
|
|
|
import logger from '@overleaf/logger'
|
|
import logger from '@overleaf/logger'
|
|
|
import express from 'express'
|
|
import express from 'express'
|
|
|
import bodyParser from 'body-parser'
|
|
import bodyParser from 'body-parser'
|
|
|
-import {
|
|
|
|
|
- celebrate as validate,
|
|
|
|
|
- Joi,
|
|
|
|
|
- errors as handleValidationErrors,
|
|
|
|
|
-} from 'celebrate'
|
|
|
|
|
|
|
+import { handleValidationError } from '@overleaf/validation-tools'
|
|
|
import mongodb from './app/js/mongodb.js'
|
|
import mongodb from './app/js/mongodb.js'
|
|
|
import Errors from './app/js/Errors.js'
|
|
import Errors from './app/js/Errors.js'
|
|
|
import HttpController from './app/js/HttpController.js'
|
|
import HttpController from './app/js/HttpController.js'
|
|
@@ -79,13 +75,6 @@ app.post(
|
|
|
app.patch(
|
|
app.patch(
|
|
|
'/project/:project_id/doc/:doc_id',
|
|
'/project/:project_id/doc/:doc_id',
|
|
|
bodyParser.json(),
|
|
bodyParser.json(),
|
|
|
- validate({
|
|
|
|
|
- body: {
|
|
|
|
|
- deleted: Joi.boolean(),
|
|
|
|
|
- name: Joi.string().when('deleted', { is: true, then: Joi.required() }),
|
|
|
|
|
- deletedAt: Joi.date().when('deleted', { is: true, then: Joi.required() }),
|
|
|
|
|
- },
|
|
|
|
|
- }),
|
|
|
|
|
HttpController.patchDoc
|
|
HttpController.patchDoc
|
|
|
)
|
|
)
|
|
|
app.delete('/project/:project_id/doc/:doc_id', (req, res) => {
|
|
app.delete('/project/:project_id/doc/:doc_id', (req, res) => {
|
|
@@ -101,7 +90,7 @@ app.get('/health_check', HttpController.healthCheck)
|
|
|
|
|
|
|
|
app.get('/status', (req, res) => res.send('docstore is alive'))
|
|
app.get('/status', (req, res) => res.send('docstore is alive'))
|
|
|
|
|
|
|
|
-app.use(handleValidationErrors())
|
|
|
|
|
|
|
+app.use(handleValidationError)
|
|
|
app.use(function (error, req, res, next) {
|
|
app.use(function (error, req, res, next) {
|
|
|
if (error instanceof Errors.NotFoundError) {
|
|
if (error instanceof Errors.NotFoundError) {
|
|
|
logger.warn({ req }, 'not found')
|
|
logger.warn({ req }, 'not found')
|