Merge pull request #1697 from appwrite/validate-function-cron

Validate cron before updating function
This commit is contained in:
Darshan
2025-02-27 18:58:33 +05:30
committed by GitHub
@@ -11,6 +11,7 @@
import { func } from '../store';
import { isValueOfStringEnum } from '$lib/helpers/types';
import { Runtime } from '@appwrite.io/console';
import { parseExpression } from 'cron-parser';
const functionId = $page.params.function;
let functionSchedule: string = null;
@@ -24,6 +25,10 @@
if (!isValueOfStringEnum(Runtime, $func.runtime)) {
throw new Error(`Invalid runtime: ${$func.runtime}`);
}
// an error is shown if invalid.
parseExpression(functionSchedule);
await sdk.forProject.functions.update(
functionId,
$func.name,