mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Migrate MockV1HistoryApi to zod
GitOrigin-RevId: d0fd392e76632e12832fb794d60b50a0835f3756
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
|||||||
zipAttachment,
|
zipAttachment,
|
||||||
prepareZipAttachment,
|
prepareZipAttachment,
|
||||||
} from '../../../../app/src/infrastructure/Response.js'
|
} from '../../../../app/src/infrastructure/Response.js'
|
||||||
import Joi from 'joi'
|
import { z } from 'zod'
|
||||||
|
|
||||||
class MockV1HistoryApi extends AbstractMockApi {
|
class MockV1HistoryApi extends AbstractMockApi {
|
||||||
reset() {
|
reset() {
|
||||||
@@ -173,10 +173,10 @@ class MockV1HistoryApi extends AbstractMockApi {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.app.post('/api/projects/:project_id/blobs/:hash', (req, res, next) => {
|
this.app.post('/api/projects/:project_id/blobs/:hash', (req, res, next) => {
|
||||||
const schema = Joi.object({
|
const schema = z.object({
|
||||||
copyFrom: Joi.number().required(),
|
copyFrom: z.coerce.number(),
|
||||||
})
|
})
|
||||||
const { error } = schema.validate(req.query)
|
const { error } = schema.safeParse(req.query)
|
||||||
if (error) {
|
if (error) {
|
||||||
return res.sendStatus(400)
|
return res.sendStatus(400)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user