refactoring and adding capability to recognize more schedules
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
mightypanders
2022-04-13 21:38:59 +02:00
parent 9df18575fd
commit 180c467826
8 changed files with 165 additions and 98 deletions

13
server/helper/typeFind.ts Normal file
View File

@ -0,0 +1,13 @@
import { scheduleNames, supportedSchedule } from "../types/scheduledEventTypes";
export function findInScheduleTypes(inputString: string): supportedSchedule {
const maybeScheduleName: unknown = JSON.parse(`"${inputString.toLowerCase()}"`);
const scheduleName = scheduleNames.find((validName: supportedSchedule) => validName === maybeScheduleName);
if (scheduleName) {
// `sheepName` comes from the list of `sheepNames` so the compiler is happy.
return scheduleName;
}
throw new Error('That is not a schedule name.');
}