mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
[web] core-2: adopt strict zod schema and extend test coverage GitOrigin-RevId: f26d349fefb6bf9e042cb39117395120c3f7c877
35 lines
945 B
JavaScript
35 lines
945 B
JavaScript
import EditorRealTimeController from '../Editor/EditorRealTimeController.mjs'
|
|
import { z, zz, parseReq } from '../../infrastructure/Validation.mjs'
|
|
|
|
const indexAllSchema = z.object({
|
|
params: z.strictObject({
|
|
Project_id: zz.objectId(),
|
|
}),
|
|
body: z.strictObject({
|
|
shouldBroadcast: z.boolean().optional(),
|
|
clientId: z.string().optional(),
|
|
}),
|
|
})
|
|
|
|
export default {
|
|
indexAll(req, res, next) {
|
|
const { params, body } = parseReq(req, indexAllSchema, {
|
|
logOnly: true,
|
|
})
|
|
const projectId = params.Project_id
|
|
const { shouldBroadcast, clientId } = body
|
|
// We've migrated to client side indexing, so we only use the message for
|
|
// broadcasting that the clients need to re-index.
|
|
if (shouldBroadcast) {
|
|
EditorRealTimeController.emitToRoom(
|
|
projectId,
|
|
'references:keys:updated',
|
|
[],
|
|
true,
|
|
clientId
|
|
)
|
|
}
|
|
res.json({ projectId, keys: [] })
|
|
},
|
|
}
|