2024-06-13 09:23:12 +02:00
|
|
|
import {
|
|
|
|
AbortRunnerJobBody,
|
|
|
|
AcceptRunnerJobResult,
|
|
|
|
ErrorRunnerJobBody,
|
|
|
|
HttpStatusCode,
|
|
|
|
ListRunnerJobsQuery,
|
|
|
|
LiveRTMPHLSTranscodingUpdatePayload,
|
|
|
|
RequestRunnerJobResult,
|
|
|
|
RunnerJobState,
|
|
|
|
RunnerJobSuccessBody,
|
|
|
|
RunnerJobSuccessPayload,
|
|
|
|
RunnerJobType,
|
|
|
|
RunnerJobUpdateBody,
|
|
|
|
RunnerJobUpdatePayload,
|
|
|
|
ServerErrorCode,
|
|
|
|
TranscriptionSuccess,
|
|
|
|
UserRight,
|
|
|
|
VODAudioMergeTranscodingSuccess,
|
|
|
|
VODHLSTranscodingSuccess,
|
|
|
|
VODWebVideoTranscodingSuccess,
|
|
|
|
VideoStudioTranscodingSuccess
|
|
|
|
} from '@peertube/peertube-models'
|
2023-07-31 14:34:36 +02:00
|
|
|
import { retryTransactionWrapper } from '@server/helpers/database-utils.js'
|
|
|
|
import { createReqFiles } from '@server/helpers/express-utils.js'
|
|
|
|
import { logger, loggerTagsFactory } from '@server/helpers/logger.js'
|
|
|
|
import { generateRunnerJobToken } from '@server/helpers/token-generator.js'
|
|
|
|
import { MIMETYPES } from '@server/initializers/constants.js'
|
|
|
|
import { sequelizeTypescript } from '@server/initializers/database.js'
|
|
|
|
import { getRunnerJobHandlerClass, runnerJobCanBeCancelled, updateLastRunnerContact } from '@server/lib/runners/index.js'
|
2023-04-21 14:55:10 +02:00
|
|
|
import {
|
2023-06-20 14:17:34 +02:00
|
|
|
apiRateLimiter,
|
2023-04-21 14:55:10 +02:00
|
|
|
asyncMiddleware,
|
|
|
|
authenticate,
|
|
|
|
ensureUserHasRight,
|
|
|
|
paginationValidator,
|
|
|
|
runnerJobsSortValidator,
|
|
|
|
setDefaultPagination,
|
|
|
|
setDefaultSort
|
2023-07-31 14:34:36 +02:00
|
|
|
} from '@server/middlewares/index.js'
|
2023-04-21 14:55:10 +02:00
|
|
|
import {
|
|
|
|
abortRunnerJobValidator,
|
|
|
|
acceptRunnerJobValidator,
|
2023-05-04 15:29:34 +02:00
|
|
|
cancelRunnerJobValidator,
|
2023-04-21 14:55:10 +02:00
|
|
|
errorRunnerJobValidator,
|
|
|
|
getRunnerFromTokenValidator,
|
2023-07-12 11:09:29 +02:00
|
|
|
jobOfRunnerGetValidatorFactory,
|
2023-07-27 11:44:31 +02:00
|
|
|
listRunnerJobsValidator,
|
2023-04-21 14:55:10 +02:00
|
|
|
runnerJobGetValidator,
|
|
|
|
successRunnerJobValidator,
|
|
|
|
updateRunnerJobValidator
|
2023-07-31 14:34:36 +02:00
|
|
|
} from '@server/middlewares/validators/runners/index.js'
|
|
|
|
import { RunnerJobModel } from '@server/models/runner/runner-job.js'
|
2024-06-13 09:23:12 +02:00
|
|
|
import { RunnerModel } from '@server/models/runner/runner.js'
|
|
|
|
import express, { UploadFiles } from 'express'
|
2023-04-21 14:55:10 +02:00
|
|
|
|
|
|
|
const postRunnerJobSuccessVideoFiles = createReqFiles(
|
2024-06-13 09:23:12 +02:00
|
|
|
[ 'payload[videoFile]', 'payload[resolutionPlaylistFile]', 'payload[vttFile]' ],
|
|
|
|
{ ...MIMETYPES.VIDEO.MIMETYPE_EXT, ...MIMETYPES.M3U8.MIMETYPE_EXT, ...MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT }
|
2023-04-21 14:55:10 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
const runnerJobUpdateVideoFiles = createReqFiles(
|
|
|
|
[ 'payload[videoChunkFile]', 'payload[resolutionPlaylistFile]', 'payload[masterPlaylistFile]' ],
|
|
|
|
{ ...MIMETYPES.VIDEO.MIMETYPE_EXT, ...MIMETYPES.M3U8.MIMETYPE_EXT }
|
|
|
|
)
|
|
|
|
|
|
|
|
const lTags = loggerTagsFactory('api', 'runner')
|
|
|
|
|
|
|
|
const runnerJobsRouter = express.Router()
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Controllers for runners
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
runnerJobsRouter.post('/jobs/request',
|
2023-06-20 14:17:34 +02:00
|
|
|
apiRateLimiter,
|
2023-04-21 14:55:10 +02:00
|
|
|
asyncMiddleware(getRunnerFromTokenValidator),
|
|
|
|
asyncMiddleware(requestRunnerJob)
|
|
|
|
)
|
|
|
|
|
|
|
|
runnerJobsRouter.post('/jobs/:jobUUID/accept',
|
2023-06-20 14:17:34 +02:00
|
|
|
apiRateLimiter,
|
2023-04-21 14:55:10 +02:00
|
|
|
asyncMiddleware(runnerJobGetValidator),
|
|
|
|
acceptRunnerJobValidator,
|
|
|
|
asyncMiddleware(getRunnerFromTokenValidator),
|
|
|
|
asyncMiddleware(acceptRunnerJob)
|
|
|
|
)
|
|
|
|
|
|
|
|
runnerJobsRouter.post('/jobs/:jobUUID/abort',
|
2023-06-20 14:17:34 +02:00
|
|
|
apiRateLimiter,
|
2023-07-12 11:09:29 +02:00
|
|
|
asyncMiddleware(jobOfRunnerGetValidatorFactory([ RunnerJobState.PROCESSING ])),
|
2023-04-21 14:55:10 +02:00
|
|
|
abortRunnerJobValidator,
|
|
|
|
asyncMiddleware(abortRunnerJob)
|
|
|
|
)
|
|
|
|
|
|
|
|
runnerJobsRouter.post('/jobs/:jobUUID/update',
|
|
|
|
runnerJobUpdateVideoFiles,
|
2023-06-20 14:17:34 +02:00
|
|
|
apiRateLimiter, // Has to be after multer middleware to parse runner token
|
2023-07-12 11:09:29 +02:00
|
|
|
asyncMiddleware(jobOfRunnerGetValidatorFactory([ RunnerJobState.PROCESSING, RunnerJobState.COMPLETING, RunnerJobState.COMPLETED ])),
|
2023-04-21 14:55:10 +02:00
|
|
|
updateRunnerJobValidator,
|
|
|
|
asyncMiddleware(updateRunnerJobController)
|
|
|
|
)
|
|
|
|
|
|
|
|
runnerJobsRouter.post('/jobs/:jobUUID/error',
|
2023-07-12 11:09:29 +02:00
|
|
|
asyncMiddleware(jobOfRunnerGetValidatorFactory([ RunnerJobState.PROCESSING ])),
|
2023-04-21 14:55:10 +02:00
|
|
|
errorRunnerJobValidator,
|
|
|
|
asyncMiddleware(errorRunnerJob)
|
|
|
|
)
|
|
|
|
|
|
|
|
runnerJobsRouter.post('/jobs/:jobUUID/success',
|
|
|
|
postRunnerJobSuccessVideoFiles,
|
2023-06-20 14:17:34 +02:00
|
|
|
apiRateLimiter, // Has to be after multer middleware to parse runner token
|
2023-07-12 11:09:29 +02:00
|
|
|
asyncMiddleware(jobOfRunnerGetValidatorFactory([ RunnerJobState.PROCESSING ])),
|
2023-04-21 14:55:10 +02:00
|
|
|
successRunnerJobValidator,
|
|
|
|
asyncMiddleware(postRunnerJobSuccess)
|
|
|
|
)
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Controllers for admins
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
runnerJobsRouter.post('/jobs/:jobUUID/cancel',
|
|
|
|
authenticate,
|
|
|
|
ensureUserHasRight(UserRight.MANAGE_RUNNERS),
|
|
|
|
asyncMiddleware(runnerJobGetValidator),
|
2023-05-04 15:29:34 +02:00
|
|
|
cancelRunnerJobValidator,
|
2023-04-21 14:55:10 +02:00
|
|
|
asyncMiddleware(cancelRunnerJob)
|
|
|
|
)
|
|
|
|
|
|
|
|
runnerJobsRouter.get('/jobs',
|
|
|
|
authenticate,
|
|
|
|
ensureUserHasRight(UserRight.MANAGE_RUNNERS),
|
|
|
|
paginationValidator,
|
|
|
|
runnerJobsSortValidator,
|
|
|
|
setDefaultSort,
|
|
|
|
setDefaultPagination,
|
2023-07-27 11:44:31 +02:00
|
|
|
listRunnerJobsValidator,
|
2023-04-21 14:55:10 +02:00
|
|
|
asyncMiddleware(listRunnerJobs)
|
|
|
|
)
|
|
|
|
|
2023-07-27 11:44:31 +02:00
|
|
|
runnerJobsRouter.delete('/jobs/:jobUUID',
|
|
|
|
authenticate,
|
|
|
|
ensureUserHasRight(UserRight.MANAGE_RUNNERS),
|
|
|
|
asyncMiddleware(runnerJobGetValidator),
|
|
|
|
asyncMiddleware(deleteRunnerJob)
|
|
|
|
)
|
|
|
|
|
2023-04-21 14:55:10 +02:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
runnerJobsRouter
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Controllers for runners
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
async function requestRunnerJob (req: express.Request, res: express.Response) {
|
|
|
|
const runner = res.locals.runner
|
|
|
|
const availableJobs = await RunnerJobModel.listAvailableJobs()
|
|
|
|
|
|
|
|
logger.debug('Runner %s requests for a job.', runner.name, { availableJobs, ...lTags(runner.name) })
|
|
|
|
|
|
|
|
const result: RequestRunnerJobResult = {
|
|
|
|
availableJobs: availableJobs.map(j => ({
|
|
|
|
uuid: j.uuid,
|
|
|
|
type: j.type,
|
|
|
|
payload: j.payload
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
updateLastRunnerContact(req, runner)
|
|
|
|
|
|
|
|
return res.json(result)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function acceptRunnerJob (req: express.Request, res: express.Response) {
|
|
|
|
const runner = res.locals.runner
|
|
|
|
const runnerJob = res.locals.runnerJob
|
|
|
|
|
2023-05-17 14:47:17 +02:00
|
|
|
const newRunnerJob = await retryTransactionWrapper(() => {
|
|
|
|
return sequelizeTypescript.transaction(async transaction => {
|
|
|
|
await runnerJob.reload({ transaction })
|
2023-04-21 14:55:10 +02:00
|
|
|
|
2023-05-17 14:47:17 +02:00
|
|
|
if (runnerJob.state !== RunnerJobState.PENDING) {
|
|
|
|
res.fail({
|
2023-05-19 09:23:20 +02:00
|
|
|
type: ServerErrorCode.RUNNER_JOB_NOT_IN_PENDING_STATE,
|
2023-05-17 14:47:17 +02:00
|
|
|
message: 'This job is not in pending state anymore',
|
|
|
|
status: HttpStatusCode.CONFLICT_409
|
|
|
|
})
|
|
|
|
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
|
|
|
|
runnerJob.state = RunnerJobState.PROCESSING
|
|
|
|
runnerJob.processingJobToken = generateRunnerJobToken()
|
|
|
|
runnerJob.startedAt = new Date()
|
|
|
|
runnerJob.runnerId = runner.id
|
|
|
|
|
|
|
|
return runnerJob.save({ transaction })
|
|
|
|
})
|
2023-04-21 14:55:10 +02:00
|
|
|
})
|
2023-05-17 14:47:17 +02:00
|
|
|
if (!newRunnerJob) return
|
|
|
|
|
2023-04-21 14:55:10 +02:00
|
|
|
newRunnerJob.Runner = runner as RunnerModel
|
|
|
|
|
|
|
|
const result: AcceptRunnerJobResult = {
|
|
|
|
job: {
|
|
|
|
...newRunnerJob.toFormattedJSON(),
|
|
|
|
|
|
|
|
jobToken: newRunnerJob.processingJobToken
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateLastRunnerContact(req, runner)
|
|
|
|
|
|
|
|
logger.info(
|
|
|
|
'Remote runner %s has accepted job %s (%s)', runner.name, runnerJob.uuid, runnerJob.type,
|
|
|
|
lTags(runner.name, runnerJob.uuid, runnerJob.type)
|
|
|
|
)
|
|
|
|
|
|
|
|
return res.json(result)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function abortRunnerJob (req: express.Request, res: express.Response) {
|
|
|
|
const runnerJob = res.locals.runnerJob
|
|
|
|
const runner = runnerJob.Runner
|
|
|
|
const body: AbortRunnerJobBody = req.body
|
|
|
|
|
|
|
|
logger.info(
|
|
|
|
'Remote runner %s is aborting job %s (%s)', runner.name, runnerJob.uuid, runnerJob.type,
|
|
|
|
{ reason: body.reason, ...lTags(runner.name, runnerJob.uuid, runnerJob.type) }
|
|
|
|
)
|
|
|
|
|
|
|
|
const RunnerJobHandler = getRunnerJobHandlerClass(runnerJob)
|
|
|
|
await new RunnerJobHandler().abort({ runnerJob })
|
|
|
|
|
|
|
|
updateLastRunnerContact(req, runnerJob.Runner)
|
|
|
|
|
|
|
|
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function errorRunnerJob (req: express.Request, res: express.Response) {
|
|
|
|
const runnerJob = res.locals.runnerJob
|
|
|
|
const runner = runnerJob.Runner
|
|
|
|
const body: ErrorRunnerJobBody = req.body
|
|
|
|
|
|
|
|
runnerJob.failures += 1
|
|
|
|
|
|
|
|
logger.error(
|
|
|
|
'Remote runner %s had an error with job %s (%s)', runner.name, runnerJob.uuid, runnerJob.type,
|
|
|
|
{ errorMessage: body.message, totalFailures: runnerJob.failures, ...lTags(runner.name, runnerJob.uuid, runnerJob.type) }
|
|
|
|
)
|
|
|
|
|
|
|
|
const RunnerJobHandler = getRunnerJobHandlerClass(runnerJob)
|
|
|
|
await new RunnerJobHandler().error({ runnerJob, message: body.message })
|
|
|
|
|
|
|
|
updateLastRunnerContact(req, runnerJob.Runner)
|
|
|
|
|
|
|
|
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
const jobUpdateBuilders: {
|
|
|
|
[id in RunnerJobType]?: (payload: RunnerJobUpdatePayload, files?: UploadFiles) => RunnerJobUpdatePayload
|
|
|
|
} = {
|
|
|
|
'live-rtmp-hls-transcoding': (payload: LiveRTMPHLSTranscodingUpdatePayload, files) => {
|
|
|
|
return {
|
|
|
|
...payload,
|
|
|
|
|
|
|
|
masterPlaylistFile: files['payload[masterPlaylistFile]']?.[0].path,
|
|
|
|
resolutionPlaylistFile: files['payload[resolutionPlaylistFile]']?.[0].path,
|
|
|
|
videoChunkFile: files['payload[videoChunkFile]']?.[0].path
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function updateRunnerJobController (req: express.Request, res: express.Response) {
|
|
|
|
const runnerJob = res.locals.runnerJob
|
|
|
|
const runner = runnerJob.Runner
|
|
|
|
const body: RunnerJobUpdateBody = req.body
|
|
|
|
|
2023-07-12 11:09:29 +02:00
|
|
|
if (runnerJob.state === RunnerJobState.COMPLETING || runnerJob.state === RunnerJobState.COMPLETED) {
|
|
|
|
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
|
|
|
}
|
|
|
|
|
2023-04-21 14:55:10 +02:00
|
|
|
const payloadBuilder = jobUpdateBuilders[runnerJob.type]
|
|
|
|
const updatePayload = payloadBuilder
|
|
|
|
? payloadBuilder(body.payload, req.files as UploadFiles)
|
|
|
|
: undefined
|
|
|
|
|
|
|
|
logger.debug(
|
|
|
|
'Remote runner %s is updating job %s (%s)', runnerJob.Runner.name, runnerJob.uuid, runnerJob.type,
|
|
|
|
{ body, updatePayload, ...lTags(runner.name, runnerJob.uuid, runnerJob.type) }
|
|
|
|
)
|
|
|
|
|
|
|
|
const RunnerJobHandler = getRunnerJobHandlerClass(runnerJob)
|
|
|
|
await new RunnerJobHandler().update({
|
|
|
|
runnerJob,
|
|
|
|
progress: req.body.progress,
|
|
|
|
updatePayload
|
|
|
|
})
|
|
|
|
|
|
|
|
updateLastRunnerContact(req, runnerJob.Runner)
|
|
|
|
|
|
|
|
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
const jobSuccessPayloadBuilders: {
|
|
|
|
[id in RunnerJobType]: (payload: RunnerJobSuccessPayload, files?: UploadFiles) => RunnerJobSuccessPayload
|
|
|
|
} = {
|
|
|
|
'vod-web-video-transcoding': (payload: VODWebVideoTranscodingSuccess, files) => {
|
|
|
|
return {
|
|
|
|
...payload,
|
|
|
|
|
|
|
|
videoFile: files['payload[videoFile]'][0].path
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'vod-hls-transcoding': (payload: VODHLSTranscodingSuccess, files) => {
|
|
|
|
return {
|
|
|
|
...payload,
|
|
|
|
|
|
|
|
videoFile: files['payload[videoFile]'][0].path,
|
|
|
|
resolutionPlaylistFile: files['payload[resolutionPlaylistFile]'][0].path
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'vod-audio-merge-transcoding': (payload: VODAudioMergeTranscodingSuccess, files) => {
|
|
|
|
return {
|
|
|
|
...payload,
|
|
|
|
|
|
|
|
videoFile: files['payload[videoFile]'][0].path
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-05-04 15:55:51 +02:00
|
|
|
'video-studio-transcoding': (payload: VideoStudioTranscodingSuccess, files) => {
|
2023-05-04 15:29:34 +02:00
|
|
|
return {
|
|
|
|
...payload,
|
|
|
|
|
|
|
|
videoFile: files['payload[videoFile]'][0].path
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2024-06-13 09:23:12 +02:00
|
|
|
'live-rtmp-hls-transcoding': () => ({}),
|
|
|
|
|
|
|
|
'video-transcription': (payload: TranscriptionSuccess, files) => {
|
|
|
|
return {
|
|
|
|
...payload,
|
|
|
|
|
|
|
|
vttFile: files['payload[vttFile]'][0].path
|
|
|
|
}
|
|
|
|
}
|
2023-04-21 14:55:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async function postRunnerJobSuccess (req: express.Request, res: express.Response) {
|
|
|
|
const runnerJob = res.locals.runnerJob
|
|
|
|
const runner = runnerJob.Runner
|
|
|
|
const body: RunnerJobSuccessBody = req.body
|
|
|
|
|
|
|
|
const resultPayload = jobSuccessPayloadBuilders[runnerJob.type](body.payload, req.files as UploadFiles)
|
|
|
|
|
|
|
|
logger.info(
|
|
|
|
'Remote runner %s is sending success result for job %s (%s)', runnerJob.Runner.name, runnerJob.uuid, runnerJob.type,
|
|
|
|
{ resultPayload, ...lTags(runner.name, runnerJob.uuid, runnerJob.type) }
|
|
|
|
)
|
|
|
|
|
|
|
|
const RunnerJobHandler = getRunnerJobHandlerClass(runnerJob)
|
|
|
|
await new RunnerJobHandler().complete({ runnerJob, resultPayload })
|
|
|
|
|
|
|
|
updateLastRunnerContact(req, runnerJob.Runner)
|
|
|
|
|
|
|
|
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Controllers for admins
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
async function cancelRunnerJob (req: express.Request, res: express.Response) {
|
|
|
|
const runnerJob = res.locals.runnerJob
|
|
|
|
|
2023-05-04 15:29:34 +02:00
|
|
|
logger.info('Cancelling job %s (%s)', runnerJob.uuid, runnerJob.type, lTags(runnerJob.uuid, runnerJob.type))
|
2023-04-21 14:55:10 +02:00
|
|
|
|
|
|
|
const RunnerJobHandler = getRunnerJobHandlerClass(runnerJob)
|
|
|
|
await new RunnerJobHandler().cancel({ runnerJob })
|
|
|
|
|
|
|
|
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
|
|
|
}
|
|
|
|
|
2023-07-27 11:44:31 +02:00
|
|
|
async function deleteRunnerJob (req: express.Request, res: express.Response) {
|
|
|
|
const runnerJob = res.locals.runnerJob
|
|
|
|
|
|
|
|
logger.info('Deleting job %s (%s)', runnerJob.uuid, runnerJob.type, lTags(runnerJob.uuid, runnerJob.type))
|
|
|
|
|
|
|
|
if (runnerJobCanBeCancelled(runnerJob)) {
|
|
|
|
const RunnerJobHandler = getRunnerJobHandlerClass(runnerJob)
|
|
|
|
await new RunnerJobHandler().cancel({ runnerJob })
|
|
|
|
}
|
|
|
|
|
|
|
|
await runnerJob.destroy()
|
|
|
|
|
|
|
|
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
|
|
|
}
|
|
|
|
|
2023-04-21 14:55:10 +02:00
|
|
|
async function listRunnerJobs (req: express.Request, res: express.Response) {
|
|
|
|
const query: ListRunnerJobsQuery = req.query
|
|
|
|
|
|
|
|
const resultList = await RunnerJobModel.listForApi({
|
|
|
|
start: query.start,
|
|
|
|
count: query.count,
|
|
|
|
sort: query.sort,
|
2023-07-27 11:44:31 +02:00
|
|
|
search: query.search,
|
|
|
|
stateOneOf: query.stateOneOf
|
2023-04-21 14:55:10 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
return res.json({
|
|
|
|
total: resultList.total,
|
|
|
|
data: resultList.data.map(d => d.toFormattedAdminJSON())
|
|
|
|
})
|
|
|
|
}
|