PeerTube/server/core/helpers/custom-validators/jobs.ts

22 lines
603 B
TypeScript
Raw Normal View History

import { JobState } from '@peertube/peertube-models'
import { jobTypes } from '@server/lib/job-queue/job-queue.js'
import { exists } from './misc.js'
2022-08-08 03:42:08 -05:00
const jobStates: JobState[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed', 'paused', 'waiting-children' ]
function isValidJobState (value: JobState) {
2019-12-04 07:49:59 -06:00
return exists(value) && jobStates.includes(value)
}
function isValidJobType (value: any) {
return exists(value) && jobTypes.includes(value)
}
// ---------------------------------------------------------------------------
export {
2020-12-13 12:27:25 -06:00
jobStates,
2019-12-04 07:49:59 -06:00
isValidJobState,
isValidJobType
}