1
0
Fork 0
peertube/server/helpers/custom-validators/jobs.ts

22 lines
574 B
TypeScript
Raw Normal View History

import { JobState } from '../../../shared/models'
import { exists } from './misc'
2019-12-04 13:49:59 +00:00
import { jobTypes } from '@server/lib/job-queue/job-queue'
2020-12-14 11:00:35 +00:00
const jobStates: JobState[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed', 'paused' ]
function isValidJobState (value: JobState) {
2019-12-04 13:49:59 +00:00
return exists(value) && jobStates.includes(value)
}
function isValidJobType (value: any) {
return exists(value) && jobTypes.includes(value)
}
// ---------------------------------------------------------------------------
export {
2020-12-13 18:27:25 +00:00
jobStates,
2019-12-04 13:49:59 +00:00
isValidJobState,
isValidJobType
}